Android 处理空列表的方法(必看篇)
更新时间:2017年04月18日 10:13:33 投稿:jingxian
下面小编就为大家带来一篇Android 处理空列表的方法(必看篇)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
android中ListView 用来展示数据,如果列表为空的状态,可以通过setEmpty(View)方法设置为空时显示的内容。
布局xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ListView android:id="@+id/my_list_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <ImageView android:id="@+id/empty_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/empty_view" /> </FrameLayout>
代码:
public class Hack24Activity extends Activity { private ListView mListView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hack24); mListView = (ListView) findViewById(R.id.my_list_view); mListView.setEmptyView(findViewById(R.id.empty_view)); } }
以上这篇Android 处理空列表的方法(必看篇)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
在Android Studio中Parcelable插件的简单使用教程
下面小编就为大家分享一篇在Android Studio中Parcelable插件的简单使用教程,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2017-11-11Android添加glide库报错Error: Failed to resolve: com.android.suppo
这篇文章主要给大家介绍了关于Android添加glide库报错Error: Failed to resolve: com.android.support:support-annotations:26.0.2的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起看看吧。2017-11-11Android使用SlidingPaneLayout 实现仿微信的滑动返回
这篇文章主要介绍了Android使用SlidingPaneLayout 实现仿微信的滑动返回,需要的朋友可以参考下2018-04-04
最新评论