Zeigen Sie TextView für eine leere ListView in einem FrameLayout an
Ich habe ein Layout mit Registerkarten und eine Aktivität, bei der Registerkarten als Ansichten verwendet werden. Es hat drei Registerkarten alsListViews
. Wenn eine der Listen leer ist, möchte ich eine einfache zeigenTextView
stattdessen. Ich habe viele Posts durchgesehen, aber alle sprechen von einem einzigenListView
in einemLinearLayout
. Ich bin mir nicht sicher, ob es wegen multipler nicht funktioniertListViews
oderFrameLayout
. Können wir nicht einstellenSichtbarkeit = GONE in einemFrameLayout
? Denn auch dann dieTextView
wird immer zusammen mit dem angezeigtListView
. Kann jemand vorschlagen, was in diesem Szenario getan werden kann?
Ich habe auch versucht, darunterTextView
in einer anderen XML-Datei. Aber ich bin mir nicht sicher, wie ich das hinzufügen sollTextView
zu meinemFrameLayout
.
Das mache ich für alle dreiListViews
TextView empty = (TextView) findViewById(R.id.blank);
FrameLayout frameLayout = (FrameLayout) findViewById(android.R.id.tabcontent);
mListView_top10 = (ListView)findViewById(R.id.Top_10);
if(TopWR.size()!=0) {
mListView_top10.setAdapter(new ArrayAdapter<String>(this, R.layout.listview_row,TopWR));
} else {
frameLayout.addView(empty);
}
FrameLayout
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/innerdashboard_bg"
android:layout_weight="1">
<ListView
android:id="@+id/Top_10"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is a tab" />
<ListView
android:id="@+id/Billable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is another tab" />
<ListView
android:id="@+id/Product"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:textSize="14sp"
android:text="this is a third tab" />
</FrameLayout>
Textvorschau
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/blank"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No records Avaible"
android:textColor="#ffffff" />
BEARBEITEN
Ich habe auch versucht mitsetEmptyView
für alle dreiListViews
Verwenden von separaten leeren Ansichten, funktioniert nicht!
TextView empty1 = (TextView) findViewById(R.id.blank1);
mListView_top10 = (ListView)findViewById(R.id.Top_10);
mListView_top10.setEmptyView(empty1);
mListView_top10.setAdapter(new ArrayAdapter<String>(this, R.layout.listview_row,TopWR));
xml:
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/innerdashboard_bg"
android:layout_weight="1">
<LinearLayout
android:id="@+id/Top_10"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/Top_10"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is a tab" />
<TextView
android:id="@+id/blank1"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No records Avaible"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/Billable"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/Billable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is another tab" />
<TextView
android:id="@+id/blank2"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No records Avaible"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/Product"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/Product"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:textSize="14sp"
android:text="this is a third tab" />
<TextView
android:id="@+id/blank3"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No records Avaible"
android:textColor="#ffffff" />
</LinearLayout>
</FrameLayout>