本文来自:安卓航班网

       Android中提供了大量的适配器Adapter,常见的有BaseAdapter、SimpleCursorAdapter、CursorAdapter等等,其中包含Cursor可以自动和数据库关联。一般在ListView中我们需要定义一些显示的内容,需要用到继承Adapter实现窗口的子类化。
       一般我们需要重写Adapter类的四个方法即可,分别是public int getCount() 、public Object getItem(int position)、public long getItemId(int position)
和public View getView(int position, View convertView, ViewGroup parent) ,调用时仍然是在ListView或ListActivity中直接setAdapter(CustomAdapter);即可,比较典型的方法参考Android的自带控件Gallery的实现,详细的在API Demo中查找即可。

原文地址:http://www.apkway.com/forum.php?mod=viewthread&tid=2812&extra=page%3D1

posted on 2011-08-16 21:45  泉と緣  阅读(307)  评论(0编辑  收藏  举报