首页 文章 精选 留言 我的

精选列表

搜索[财政票据应用],共10012篇文章
优秀的个人博客,低调大师

Android -- PullToRefresh应用

PullToRefresh 支持ListView、ExpandableListView、GridView、WebView 下载地址:https://github.com/chrisbanes/Android-PullToRefresh 注意,若是要放到android studio中的话,需要在eclipse中以android studio工程的方式导出。 Code 布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MyActivity"> <com.handmark.pulltorefresh.library.PullToRefreshListView android:id="@+id/lv_main" android:layout_width="fill_parent" android:layout_height="fill_parent"></com.handmark.pulltorefresh.library.PullToRefreshListView> </LinearLayout> 配置: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mList = new ArrayList<String>(); for (int i = 0; i < mStr.length; i++) { mList.add(mStr[i]); } mListView = (PullToRefreshListView) findViewById(R.id.lv_main); // mListView.setOnRefreshListener(new MyRefreshListener()); mListView.setOnRefreshListener(new MyRefreshListener2()); mMyAdapter = new MyAdapter(); mListView.setAdapter(mMyAdapter); mListView.setMode(PullToRefreshBase.Mode.BOTH); mListView.getLoadingLayoutProxy().setLastUpdatedLabel("setLastUpdatedLabel"); mListView.getLoadingLayoutProxy().setLoadingDrawable(getResources().getDrawable(R.drawable.ic_launcher)); mListView.getLoadingLayoutProxy().setPullLabel("setPullLabel"); mListView.getLoadingLayoutProxy().setRefreshingLabel("setRefreshingLabel"); mListView.getLoadingLayoutProxy().setReleaseLabel("setReleaseLabel"); } PullToRefreshBase.Mode.BOTH指的是下拉和上拉刷新两张模式。 class MyRefreshListener implements PullToRefreshBase.OnRefreshListener { @Override public void onRefresh(PullToRefreshBase refreshView) { } } class MyRefreshListener2 implements PullToRefreshBase.OnRefreshListener2 { @Override public void onPullDownToRefresh(PullToRefreshBase refreshView) { mList.clear(); for (int i = 0; i < mStr.length; i++) { mList.add(mStr[i]); } new Thread(new MyRunnable()).start(); } @Override public void onPullUpToRefresh(PullToRefreshBase refreshView) { for (int i = 0; i < mStr.length; i++) { mList.add(mStr[i]); } new Thread(new MyRunnable()).start(); } } 这里有两个监听器,我们来简单说一下PullToRefreshBase.OnRefreshListener2 ,很明显,分别指的是一个是上拉,一个是下拉的刷新的回调。 public class MyActivity extends Activity { private PullToRefreshListView mListView;//pulltorefresh控件 private List<String> mList;//存放数据 private String[] mStr = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"};//数据 private MyAdapter mMyAdapter;//适配器 //一个延时,然后处理 private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case 1: Log.i("handleMessage", "handleMessage"); mListView.onRefreshComplete(); mMyAdapter.notifyDataSetChanged(); break; } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mList = new ArrayList<String>();//初始化 for (int i = 0; i < mStr.length; i++) { mList.add(mStr[i]);//准备数据 } mListView = (PullToRefreshListView) findViewById(R.id.lv_main); // mListView.setOnRefreshListener(new MyRefreshListener()); mListView.setOnRefreshListener(new MyRefreshListener2());//设置监听器 mMyAdapter = new MyAdapter();//初始化适配器 mListView.setAdapter(mMyAdapter); mListView.setMode(PullToRefreshBase.Mode.BOTH);//模式为上拉和下拉 mListView.getLoadingLayoutProxy().setLastUpdatedLabel("setLastUpdatedLabel"); mListView.getLoadingLayoutProxy().setLoadingDrawable(getResources().getDrawable(R.drawable.ic_launcher));//loading的时候的图片 mListView.getLoadingLayoutProxy().setPullLabel("setPullLabel"); mListView.getLoadingLayoutProxy().setRefreshingLabel("setRefreshingLabel"); mListView.getLoadingLayoutProxy().setReleaseLabel("setReleaseLabel"); } class MyRefreshListener implements PullToRefreshBase.OnRefreshListener { @Override public void onRefresh(PullToRefreshBase refreshView) { } } class MyRefreshListener2 implements PullToRefreshBase.OnRefreshListener2 { @Override public void onPullDownToRefresh(PullToRefreshBase refreshView) { mList.clear(); for (int i = 0; i < mStr.length; i++) {//添加数据 mList.add(mStr[i]); } new Thread(new MyRunnable()).start();//执行延时 } @Override public void onPullUpToRefresh(PullToRefreshBase refreshView) { for (int i = 0; i < mStr.length; i++) {//添加数据 mList.add(mStr[i]); } new Thread(new MyRunnable()).start();//执行延时 } } class MyAdapter extends BaseAdapter { @Override public int getCount() { return mList.size(); } @Override public Object getItem(int i) { return mList.get(i); } @Override public long getItemId(int i) { return i; } @Override public View getView(int i, View view, ViewGroup viewGroup) { if (view == null) { view = LayoutInflater.from(MyActivity.this).inflate(R.layout.item, null); TextView tv = (TextView) view.findViewById(R.id.txt); tv.setText(mList.get(i)); } else { TextView tv = (TextView) view.findViewById(R.id.txt); tv.setText(mList.get(i)); } return view; } } class MyRunnable implements Runnable { @Override public void run() { try { Thread.sleep(2000);//延时2s } catch (InterruptedException e) { e.printStackTrace(); } Log.i("MyRunnable", "MyRunnable"); mHandler.sendEmptyMessage(1); } } } 我是天王盖地虎的分割线 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/4166123.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

ansible应用总结

1、常用的自动化运维工具 CFengineChefPuppet基于Ruby开发,采用C/S架构,扩展性强,基于SSL认证SaltStack基于Python开发,采用C/S架构,相对于puppet更轻量级,配置语法采用YMAL,使得配置脚本更为简单Ansible基于Pyton开发,分布式,无需客户端,轻量级,配置语言采用YAML 2、为何选择ansible 相对于puppet和saltstack,ansible无需客户端,更轻量级ansible甚至都不用启动服务,仅仅只是一个工具,可以很轻松的实现分布式扩展更强的远程命令执行操作不输于puppet和saltstack的其他功能 3、ansible基本架构 4、ansible基本组成 核心:ansible核心模块(Core Modules):这些都是ansible自带的模块 扩展模块(Custom Modules):如果核心模块不足以完成某种功能,可以添加扩展模块插件(Plugins):完成模块功能的补充剧本(Playbooks):ansible的任务配置文件,将多个任务定义在剧本中,由ansible自动执行连接插件(Connectior Plugins):ansible基于连接插件连接到各个主机上,虽然ansible是使用ssh连接到各个主机的,但是它还支持其他的连接方法,所以需要有连接插件主机群(Host Inventory):定义ansible管理的主机 5、ansible安装 配置epel源(略过) yum install ansible -y 6、ansible常用模块 file:用于配置文件属性yum:用于安装软件包cron:配置计划任务copy:复制文件到远程主机command:在远程主机上执行命令raw:类似于command模块,支持管道user:配置用户group:配置用户组service:用于管理服务ping:用于检测远程主机是否存活setup:查看远程主机的基本信息mount:配置挂载点 7、ansible简单配置 [root@martin-1 ansible]# cd /etc/ansible/ [root@martin-1 ansible]# ls ansible.cfg hosts roles [root@martin-1 ansible]# vim hosts [web]#组的名称 172.16.6.236# 这里是被ansible管理的主机 172.16.6.246 172.16.6.183 8、建立免秘钥登陆 [root@martin-1 ~]#ssh-keygen-trsa [root@martin-1 ~]#ssh-copy-id-i/root/.ssh/id_rsa.pub172.16.6.236 [root@martin-1 ~]#ssh-copy-id-i/root/.ssh/id_rsa.pub172.16.6.246 [root@martin-1 ~]#ssh-copy-id-i/root/.ssh/id_rsa.pub172.16.6.183 实例介绍 Command模块 9、palybook简介 playbook是由一个或多个“play”组成的列表。play的主要功能在于将事先归并为一组的主机装扮成事先通过ansible中的task定义好的角色。从根本上来讲,所谓task无非是调用ansible的一个module。将多个play组织在一个playbook中,即可以让它们联合起来按事先编排的机制完成某一任务 tasks 任务,即调用模块完成的某操作 variables 变量 templates 模板 handles 处理器,由某事件触发执行的操作 roles 角色 简单示例 [root@ansible scripts]# cat 2.yml - hosts: web remote_user: root tasks: - name: install apache yum: name=httpd state=latest - name: install configuration file for apache copy: src=/root/httpd.conf dest=/etc/httpd/conf/httpd.conf notify: - restart httpd - name: start httpd service service: enabled=true name=httpd state=started handlers: - name: restart httpd service: name=httpd state=restarted 安装haproxy+keepalived [root@martin-1 ansible]# tree . ├── hosts ├── roles │ ├── haproxy │ │ ├── defaults │ │ ├── files │ │ │ ├── haproxy-1.5.14-3.el7.x86_64.rpm │ │ │ └── install_haproxy.sh │ │ ├── handlers │ │ │ └── main.yml │ │ ├── meta │ │ ├── tasks │ │ │ └── main.yml │ │ ├── templates │ │ │ └── haproxy.cfg.j2 │ │ └── vars │ ├── keepalived-master │ │ ├── defaults │ │ ├── files │ │ │ ├── install_keepalived_master.sh │ │ │ └── keepalived-1.2.13-7.el7.x86_64.rpm │ │ ├── handlers │ │ │ └── main.yml │ │ ├── meta │ │ ├── tasks │ │ │ └── main.yml │ │ ├── templates │ │ │ └── keepalived.conf.j2 │ │ └── vars │ ├── keepalived-slave │ │ ├── defaults │ │ ├── files │ │ │ ├── install_keepalived_slave.sh │ │ │ └── keepalived-1.2.13-7.el7.x86_64.rpm │ │ ├── handlers │ │ │ └── main.yml │ │ ├── meta │ │ ├── tasks │ │ │ └── main.yml │ │ ├── templates │ │ │ └── keepalived.conf.j2 │ │ └── vars 10、Zabbix-agent 安装详细说明 在/目录下面建立 ansible文件夹 [root@martin-1 ansible]# pwd /ansible 目录结构如下 [root@martin-1 ansible]# tree . ├── hosts ├── roles │ └── zabbix-agent │ ├── defaults │ ├── files │ │ ├── zabbix-agent-3.2.0-1.el7.x86_64.rpm │ │ └── zabbix_agent_install.sh │ ├── handlers │ │ └── main.yml │ ├── meta │ ├── tasks │ │ └── main.yml │ ├── templates │ │ └── zabbix_agentd.conf.j2 │ └── vars │ └── main.yml └── site.yml 9 directories, 8 files 目录名称是固定的,没有用到的可以不创建如defaults目录 [root@martin-1 ansible]# cat hosts [zabbix-agent] 172.16.6.67定义需要安装zabbix-agent的服务器ip 172.16.6.65 172.16.6.76 172.16.6.77 [root@martin-1 ansible]# cat site.yml 入口文件 -name: install zabbix agent hosts: zabbix-agent remote_user: root roles: - zabbix-agent [root@martin-1 ansible]# cat roles/zabbix-agent/tasks/main.yml --- - name: cp zabbix-agent-3.2.0-1.el7.x86_64.rpm to all client copy: src=zabbix-agent-3.2.0-1.el7.x86_64.rpm dest=/tmp/ - name: cp zabbix_agent_install.sh to all client copy: src=zabbix_agent_install.sh dest=/tmp/ mode=0755 - name: execute scripts to install zabbix agent shell: /bin/bash /tmp/zabbix_agent_install.sh - name: configure zabbix agent conf template: src=zabbix_agentd.conf.j2 dest=/etc/zabbix/zabbix_agentd.conf notify: restart zabbix agent - name: Start zabbix agent service: name=zabbix-agent state=started enabled=yes 这里是自定义的任务列表,第一行表示任务名称,第二行表示使用相应的模块执行任务,所以这里需要对ansible的基本模块及常用参数有个基本了解,常用模块在上面已经说明过了,这里就不再详细说明 http://docs.ansible.com/ansible/modules_by_category.html官方各大模块说明 [root@martin-1 ansible]# cat roles/zabbix-agent/files/zabbix_agent_install.sh #!/bin/bash cd /tmp if [ ! -f zabbix-agent-3.2.0-1.el7.x86_64.rpm ];then exit 0 fi rpm -ivh zabbix-agent-3.2.0-1.el7.x86_64.rpm if [ $? -eq 0 ];then echo "zabbix-agent install succefull" else echo "zabbix-agent install failed" fi /usr/bin/cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.$(date +%F).ori 安装脚本 该任务的总体意思就是将安装包和安装脚本拷贝到远程客户端服务器上面,然后执行该安装脚本,并修改配置文件,启动zabbix-agent客户端,从这个列子可以看到ansible只是其中一个环节,假如是apigw任务(使用haproxy+keepalived来实现),需要对如下知识点比较熟悉才能较好的完成这个任务的编写 1、ansible基本模块和参数的使用 2、ansible-playbook yaml 任务格式的写法 3、负载均衡软件haproxy的需要熟悉 4、高可用软件keepalived的需要熟悉 由此:使用ansible编写任务是一个综合性的过程,并不仅仅局限于ansible本身 在安装前检查客户端是否安装了zabbix-agent 可以看到都没有安装,接下来运行palybook任务 [root@martin-1 ansible]# pwd /ansible [root@martin-1 ansible]#ansible-playbook -i hosts site.yml 检查zabbix-agent在客户端的安装和启动情况 可以看到zabbix-agent已经安装和启动完成 更多内容请参考官方网站 http://docs.ansible.com/ansible/

优秀的个人博客,低调大师

Android应用程序组件Content Provider应用实例(4)

程序使用到的界面文件定义在res/layout目录下,其中,main.xml文件定义MainActivity的界面,它的内容如下所示: <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom"> <ListView android:id="@+id/listview_article" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/border" android:choiceMode="singleChoice"> </ListView> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="10dp"> <Button android:id="@+id/button_add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="15dp" android:paddingRight="15dp" android:text="@string/add"> </Button> </LinearLayout> </LinearLayout> item.xml文件定义了ListView中每一个文章信息条目的显示界面,它的内容如下所示: <?xmlversion="1.0"encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/textview_article_title" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> <TextView android:id="@+id/textview_article_abstract" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> <TextView android:id="@+id/textview_article_url" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp"> </TextView> </LinearLayout> article.xml文件定义了ArticleActivity的界面,它的内容如下所示: <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="24dp" android:text="@string/title"> </TextView> <EditText android:id="@+id/edit_article_title" android:layout_width="fill_parent" android:layout_height="wrap_content"> </EditText> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/abs"> </TextView> <EditText android:id="@+id/edit_article_abstract" android:layout_width="fill_parent" android:layout_height="wrap_content"> </EditText> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="27dp" android:text="@string/url"> </TextView> <EditText android:id="@+id/edit_article_url" android:layout_width="fill_parent" android:layout_height="wrap_content"> </EditText> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:layout_marginTop="10dp"> <Button android:id="@+id/button_modify" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/modify"> </Button> <Button android:id="@+id/button_delete" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/delete"> </Button> <Button android:id="@+id/button_add_article" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/add"> </Button> <Button android:id="@+id/button_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/cancel"> </Button> </LinearLayout> </LinearLayout> 在res/drawable目录下,有一个border.xml文件定义了MainActivity界面上的ListView的背景,它的内容如下所示: <?xmlversion="1.0"encoding="utf-8"?> <shapexmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solidandroid:color="#ff0000ff"/> <strokeandroid:width="1dp" android:color="#000000"> </stroke> <paddingandroid:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp"> </padding> <cornersandroid:radius="10dp"/> </shape> 程序使用到的字符串资源文件定义在res/values/strings.xml文件中,它的内容如下所示: <?xmlversion="1.0"encoding="utf-8"?> <resources> <stringname="app_name">Article</string> <stringname="article">Article</string> <stringname="add">Add</string> <stringname="modify">Modify</string> <stringname="delete">Delete</string> <stringname="title">Title:</string> <stringname="abs">Abstract:</string> <stringname="url">URL:</string> <stringname="ok">OK</string> <stringname="cancel">Cancel</string> </resources> 本文转自 Luoshengyang 51CTO博客,原文链接:http://blog.51cto.com/shyluo/966944,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册