title: Show TextView for an empty ListView inside a FrameLayout
body: <p>I have a tabbed layout and an activity using tabs as views. It has three tabs as <code>ListViews</code>. If either of the lists is empty I want to show a simple <code>TextView</code> instead. I've gone through many posts but all of them talk about a single <code>ListView</code> inside a <code>LinearLayout</code>. I'm not sure if it is not working because of multiple <code>ListViews</code> or <code>FrameLayout</code>. Can we not set <strong>visibility = GONE</strong> inside a <code>FrameLayout</code>? Because even then the <code>TextView</code> is always shown along with the <code>ListView</code>. Can anyone suggest what can be done in this scenario?</p>
  
  <p>I also tried including <code>TextView</code> in another xml file. But I'm not sure how to add that <code>TextView</code> to my <code>FrameLayout</code>. </p>
  
  <p>This is what I'm doing for m all three <code>ListViews</code></p>
  
  <pre><code>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&lt;String&gt;(this, R.layout.listview_row,TopWR));
  } else {
    frameLayout.addView(empty);
  }
  </code></pre>
  
  <p>FrameLayout </p>
  
  <pre><code>&lt;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"&gt;
  
  
              &lt;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" /&gt;
  
  
          &lt;ListView 
              android:id="@+id/Billable"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" 
              android:paddingRight="5dp" 
              android:text="this is another tab" /&gt;
  
  
          &lt;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" /&gt;
  
   &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>TextView</p>
  
  <pre><code>&lt;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" /&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've also tried using <code>setEmptyView</code>, for all three <code>ListViews</code> using separate empty views, doesn't work!</p>
  
  <pre><code>TextView empty1 = (TextView) findViewById(R.id.blank1);
  mListView_top10 = (ListView)findViewById(R.id.Top_10);
  mListView_top10.setEmptyView(empty1);
  mListView_top10.setAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.listview_row,TopWR));
  </code></pre>
  
  <p>xml:</p>
  
  <pre><code>&lt;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"&gt;
  
  
          &lt;LinearLayout 
              android:id="@+id/Top_10"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
              &lt;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" /&gt;
  
              &lt;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" /&gt;
  
          &lt;/LinearLayout&gt;
  
  
          &lt;LinearLayout 
              android:id="@+id/Billable"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
          &lt;ListView 
              android:id="@+id/Billable"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" 
              android:paddingRight="5dp" 
              android:text="this is another tab" /&gt;
  
          &lt;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" /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout 
              android:id="@+id/Product"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
          &lt;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" /&gt;
  
          &lt;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" /&gt;
  
          &lt;/LinearLayout&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>