Mostrar TextView para um ListView vazio dentro de um FrameLayout
Eu tenho um layout com guias e uma atividade usando guias como visualizações. Tem três guias comoListViews
. Se alguma das listas estiver vazia, quero mostrar umaTextView
em vez de. Eu passei por muitos posts, mas todos eles falam sobre um únicoListView
dentro de umLinearLayout
. Não tenho certeza se não está funcionando por causa de múltiplosListViews
ouFrameLayout
. Não podemos definirvisibilidade = GONE dentro de umFrameLayout
? Porque mesmo assim oTextView
é sempre mostrado junto com oListView
. Alguém pode sugerir o que pode ser feito neste cenário?
Eu também tentei incluirTextView
em outro arquivo xml. Mas não tenho certeza de como adicionar issoTextView
para o meuFrameLayout
.
Isso é o que eu estou fazendo em todos os trêsListViews
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>
TextView
<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" />
EDITAR
Eu também tentei usarsetEmptyView
, para todos os trêsListViews
usando vistas vazias separadas, não funciona!
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>