资源介绍
学习笔记
estFilter.java
public class TestFilter extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList> list = new
ArrayList >();
HashMap map1 = new HashMap();
HashMap map2 = new HashMap();
HashMap map3 = new HashMap();
map1.put("name", "henly");
map1.put("age", "22");
map2.put("name", "john");
map2.put("age", "23");
map3.put("name", "lilei");
map3.put("age", "22");
list.add(map1);
list.add(map2);
list.add(map3);
SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
R.layout.user, new String[]{"name","age"}, new int[]{R.id.name,R.id.age});
String str = new String("22");
CharSequence constraint = str.subSequence(0, str.length());
Filter filter = simpleAdapter.getFilter(); //得到一个过滤器
filter.filter(constraint); //为该过滤器设置约束条件
setListAdapter(simpleAdapter);
}
- 上一篇: 安卓android开发源码
- 下一篇: [Android开发从入门到精通].扶松柏.扫描版