Android ApiDemos示例解析(175):Views->Lists->8. Photos
来源:互联网 发布:搞笑自拍软件 编辑:程序博客网 时间:2024/05/16 00:58
本例也使用了自定义ListActivity的Layout,参见上例,同时也使用了自定义的ListAdapter (PhotoAdapter) ,其getView 返回一个ImageView ,参见Android ApiDemos示例解析(119):Views->Gallery->1. Photos
注意本例R.layout.list_8.xml 中将ListView 和一个TextView,其中TextView 的id为 @+id/emtpy,放在FrameLayout中,当ListView 为空时,TextView会显示出来,显示一行文字“no photos” 表示Listview 为空:
<!– The frame layout is here since we will be showing eitherthe empty view or the list view. –><FrameLayoutandroid:layout_width=”match_parent”android:layout_height=”0dip”android:layout_weight=”1″ ><!– Here is the list. Since we are using a ListActivity, wehave to call it “@android:id/list” so ListActivity willfind it –><ListView android:id=”@android:id/list”android:layout_width=”match_parent”android:layout_height=”match_parent”android:drawSelectorOnTop=”false”/><!– Here is the view to show if the list is emtpy –><TextView android:id=”@+id/empty”android:layout_width=”match_parent”android:layout_height=”match_parent”android:text=”@string/list_8_no_photos”/></FrameLayout>
其实ListActivity提供了一个更简洁的方法为ListView设置为空时显示的View,可以在Layout使用任意一种View,只要将其id 设置为”android:id/empty”,则可以用来显示ListView为空时的UI。
本例可以动态为ListView 随机添加照片,Clear 可以清空表,注意改变ListView数据源后,要调用notifyDataSetChanged()通知UI更新屏幕.
- Android ApiDemos示例解析(175):Views->Lists->8. Photos
- Android ApiDemos示例解析(119):Views->Gallery->1. Photos
- Android ApiDemos示例解析(114):Views->Expandable Lists->3. SimpleAdapter
- Android ApiDemos示例解析(168):Views->Lists->1. Array
- Android ApiDemos示例解析(169):Views->Lists->2. Cursor(People)
- Android ApiDemos示例解析(170):Views->Lists->3. Cursor (Phones)
- Android ApiDemos示例解析(171):Views->Lists->4. ListAdapter
- Android ApiDemos示例解析(172):Views->Lists->5. Separators
- Android ApiDemos示例解析(173):Views->Lists->6. ListAdapter Collapsed
- Android ApiDemos示例解析(174):Views->Lists->7. Cursor(Phones)
- Android ApiDemos示例解析(176):Views->Lists->9. Array (Overlay)
- Android ApiDemos示例解析(179):Views->Lists->12. Transcript
- Android ApiDemos示例解析(180):Views->Lists->13. Slow Adapter
- Android ApiDemos示例解析(181):Views->Lists->14.Efficient Adapter
- Android ApiDemos示例解析(112):Views->Expandable Lists->1. Custom Adapter
- Android ApiDemos示例解析(113):Views->Expandable Lists->2. Cursor(People)
- Android ApiDemos示例解析(177):Views->Lists->10. Single choice list
- Android ApiDemos示例解析(178):Views->Lists->11. Multiple choice list
- 七夕夜、离别,涵情经河岸
- Form技巧:如果在输入Item之后,可以自动执行GO_BLOCK等内置函数
- 利用nginx+apache+mysql+php+memcached+squid搭建门户网站
- 如果不是异地
- 加载不同格式类型图片封转函数(流中加载)
- Android ApiDemos示例解析(175):Views->Lists->8. Photos
- (四) MvcContrib插件实现MVC的分页
- 关于osip协议栈的优化
- 服务器推送数据 和 客户端定时访问服务器的实现
- 数据结构队列之环形队列的动态数组实现:queue
- 黑马程序员之VS2010学习笔记:VS2010MSDN安装图解
- TCP协议三次握手过程分析
- vs断点调试需要修改的几个选项
- Segue特殊用法:UITableViewController根据参数导航到不同的子页面或自身