【发布时间】:2014-06-27 12:59:02
【问题描述】:
我想在抽屉布局的列表视图中将自定义视图显示为空视图! 我像这样在 xml 中创建一个视图并将其命名为 view_custom_empty.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFff0000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="NO RESULT"
android:textColor="#FFffffff" />
</RelativeLayout>
在我的活动中,我像这样设置列表视图 emptyview:
View emptyView = getLayoutInflater().inflate(R.layout.view_custom_empty, null);
ViewGroup viewGroup = (ViewGroup) drawerLayout.getParent();
viewGroup.addView(emptyView, 0);
drawerListview.setEmptyView(emptyView);
drawerListview.setAdapter(mDrawerAdapter);
但是当我的自定义空视图为空时,它不会出现在我的列表视图中!
【问题讨论】:
标签: android listview navigation-drawer