我有一個Activity來擴展ListActivity以顯示一些搜索結果。除非沒有結果(適配器爲空),否則一切正常,我無法使EmptyView顯示描述此內容的文本。見下面的代碼。當ListAdapter爲空時ListView.EmptyView不顯示
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var description = Intent.GetStringExtra("Description");
var partResults = this.partsClient.GetPartsSearchResults(description);
this.results = partResults;
var textView = new TextView(ListView.Context);
textView.Text = "No Results...";
this.ListView.EmptyView = textView;
this.ListAdapter = new PartsListAdapter(this, results);
}
有人能看到什麼是錯的這段代碼,爲什麼文「無結果......」不會當適配器結果是空的顯示?
不幸的是,這也沒有工作,我試圖使用標準視圖(即列表視圖與id列表和id爲空的textview)我不知所措,因爲根據文檔(如你所指出的)應該管用... – theMothaShip 2013-05-01 17:15:02