1

ListActivity を拡張して検索結果を表示する Activity があります。結果がない場合 (アダプターが空である場合) を除いて、すべて正常に動作しています。以下のコードを参照してください。

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);

    }

アダプターの結果が空のときに「結果がありません...」というテキストが表示されない理由について、このコードの何が問題なのか誰にもわかりますか?

4

2 に答える 2

0

Empty TextView を次のように設定してみてください

this.listView.setEmptyView(findViewById(R.id.emptyElement));

http://developer.android.com/reference/android/widget/AdapterView.html#setEmptyView%28android.view.View%29

于 2013-05-01T16:42:30.973 に答える