ProgressBar 使用方法
progressBar是进度条
style="?android:attr/progressBarStyleHorizontal" 这句设置进度条为水平样式的
style="?android:attr/progressBarStyle" 这种风格是默认风格(就是圆圈一直在转)
android:visibility="gone" 这句设置进度条是否可视,目前gone为不可视,通过程序使进度条成为可视状态
深色部分为主进度,浅色部分为第二进度
ListView 使用方法
SimpleAdapter listAdapter = new SimpleAdapter(this, list,
R.layout.user, new String[] { "user_name", "user_ip" },
new int[] { R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
R.layout.user, new String[] { "user_name", "user_ip" },
new int[] { R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
ListView里面就是一个个的HashMap,HashMap里面就是一个个的键值对,
R.layout.user 设置ListView的Xml文件,
new String[] { "user_name", "user_ip" }, 对应ListView的列的数量,并且HashMap中的键值对也要对应名字
new int[] { R.id.user_name,R.id.user_ip}); 控制ListVIew中的HashMap中键值对所要显示的值
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map1 = new HashMap<String, String>();
HashMap<String, String> map2 = new HashMap<String, String>();
HashMap<String, String> map3 = new HashMap<String, String>();
map1.put("user_name", "zhangsan");
map1.put("user_ip", "192.168.0.1");
map2.put("user_name", "zhangsan");
map2.put("user_ip", "192.168.0.2");
map3.put("user_name", "wangwu");
map3.put("user_ip", "192.168.0.3");
list.add(map1);
list.add(map2);
list.add(map3);
HashMap<String, String> map1 = new HashMap<String, String>();
HashMap<String, String> map2 = new HashMap<String, String>();
HashMap<String, String> map3 = new HashMap<String, String>();
map1.put("user_name", "zhangsan");
map1.put("user_ip", "192.168.0.1");
map2.put("user_name", "zhangsan");
map2.put("user_ip", "192.168.0.2");
map3.put("user_name", "wangwu");
map3.put("user_ip", "192.168.0.3");
list.add(map1);
list.add(map2);
list.add(map3);
HushMap的设置如上, list.add(map1);
list.add(map2);
list.add(map3);
list.add(map2);
list.add(map3);
把Map对象添加到List中。
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
System.out.println("id----------------" + id);
System.out.println("position----------" + position);
}
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
System.out.println("id----------------" + id);
System.out.println("position----------" + position);
}
设置点击ListView的点击发生事件。
本文主要介绍了Android中ProgressBar的使用,包括如何设置水平样式和默认圆形样式,以及如何控制其可见性。通过样例代码展示了如何让进度条在程序运行中变得可见。
1101

被折叠的 条评论
为什么被折叠?



