1
我有一个简单的ListActivity,它使用ListAdapter,我想自定义ListView。这里是我的onCreate,在这里我指定要使用视图,而不是使用()由setListAdapter生成默认的ListView:通过XML自定义ListView问题
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set the listview, empty listview
setContentView(R.layout.main);
getListView().setEmptyView(findViewById(android.R.id.empty));
// set the list properties
getListView().setOnCreateContextMenuListener(this);
.
.
.
<code snipped>
.
.
.
setListAdapter(adapter);
}
你可以看到,我设置emptyView为好。下面是XML文件的main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="vertical"
android:dividerHeight="5dp" />
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:singleLine="false"
android:text="@string/message_empty_list" />
</LinearLayout>
我的问题是,ListView控件,而正确应用dividerHeight,被忽略了:fadingEdge指令时,它在XML;但是,如果我设置fadingEdge编程,它的工作原理,即:
getListView().setVerticalFadingEdgeEnabled(true);
任何想法,为什么ListView的将是专门无视fadingEdge?我是否做了不正确的事情,可能导致这种行为?
谢谢!
我本来它的Android版本:ID /列表,我希望它是,但它并没有那么工作要么...所以我做了搜索,并在页面上这里建议其更改为来到@ id/android:list ...当然现在我找不到那个页面。无论如何,简短的回答是它仍然无法改变android:id – 2011-01-11 04:18:40