本例也使用了自定义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 either
the empty view or the list view. –>
<FrameLayout
android:layout_width=”match_parent”
android:layout_height=”0dip”
android:layout_weight=”1″ >
<!– Here is the list. Since we are using a ListActivity, we
have to call it “@android:id/list” so ListActivity will
find 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更新屏幕.
分享到:
相关推荐
NULL 博文链接:https://kakukemeit.iteye.com/blog/1806388
android apidemos代码的示例解析,讲的挺全的
Android ApiDemos apk, 包括Android presentation双屏异显 demon, App>Activity>Presentation
最新版ApiDemos Android SDK 中带有很多例子,其中ApiDemo 详细介绍了Android 平台主要API,分成了 · App · Content · Graphics · Media · OS · Text · Views 几个大类,每个大类又分为几个小类,...
demos :jdk-8u202-linux-x64-demos.tar.gz
demos :jdk-8u202-linux-arm64-vfp-hflt-demos.tar.gz
最新Android apidemos
- NEW: Draw extra 8 directions instead of 4 directions to archive text outline effect. Toggle option is UIConfig.enhancedTextOutlineEffect. - IMPROVED: Eexecution efficiency optimizations. - IMPROVED:...
从官方预览包里提取的Android6.0 ApiDemos.apk,方便安装在真机上查看实例的实际效果。
文件名称: jdk-8u231-solaris-x64-demos.tar.gz 文件大小: 8.43 MB (8,846,115 字节) MD5: 3b62803c4e86b40f1a83b68be7bce224 SHA1: 3aba5de2157163b949179a5b654494da05b4da9c SHA256: 774c5d41a1422d22d026eaaa39...
API Demos 是 Google 为了 Android 开发者所提供的一个 Android API 合集,其中包含了很多的 API 范例,同时遵循了良好的代码规范,是一个值得开发者研究和学习的典型。android的ApiDemos,需要解压缩后使用。
android APIdemos,android 源码简单使用demos
Microsoft.Premium.DP-300.by_.VCEup_.82q-DEMOS.pdf
Java附件,jdk-8u261 jdk安装包,非最新版,windows64版本 需要最新版的可以去官网自行下载, 本安装包仅用于学习
api ------------- API目录 demos ------------- 本地demos目录 lib ------------- 框架源代码目录 index.htm ------------- 主页面 loading.gif ------------- loading图标 welcome.htm ------------- 欢迎页面 ...
demos :jdk-8u202-linux-arm32-vfp-hflt-demos.tar.gz
r下载后,解压,把解压后的文件直接放入到red5webaaps下
Android 5.1的ApiDemos安装包
jdk-8u231-linux-x64-demos.tar.gz
该Api Demos 源码是基于Android6.0 ,Eclipse下的,可以直接使用Android studio 导入工程即可。