android adapter用法 Android之Adapter用法总结.doc
文本预览下载声明
android adapter用法 Android之Adapter用法总结
导读:就爱阅读网友为您分享以下“Android之Adapter用法总结”的资讯,希望对您有所帮助,感谢您对92的支持!
lt;uses-permission
android:name=quot;android.permission.READ_CONTACTSquot;gt;lt;/uses-permissiongt; 效果如下:
4)BaseAdapter
有时候,列表不光会用来做显示用,我们同样可以在在上面添加按钮。添加按钮首先要写一个有按钮的xml文件,然后自然会想到用上面的方法定义一 个适配器,然后将数据映射到布局文件上。但是事实并非这样,因为按钮是无法映射的,即使你成功的用布局文件显示出了按钮也无法添加按钮的响应,这时就要研 究一下ListView是如何现实的了,而且必须要重写一个类继承BaseAdapter。下面的示例将显示一个按钮和一个图片,两行字如果单击按钮将删 除此按钮的所在行。并告诉你ListView究竟是如何工作的。
vlist2.xml
lt;?xml version=quot;1.0quot; encoding=quot;utf-8quot;?gt;
lt;LinearLayout
xmlns:android=quot;/apk/res/androidquot;
android:orientation=quot;horizontalquot; android:layout_width=quot;fill_parentquot; android:layout_height=quot;fill_parentquot;gt;
lt;ImageView android:id=quot;@+id/imgquot;
android:layout_width=quot;wrap_contentquot;
android:layout_height=quot;wrap_contentquot; android:layout_margin=quot;5pxquot;/gt; lt;LinearLayout android:orientation=quot;verticalquot;
显示全部