title: How do I display a TextView when a ListView is empty?
body: <p>I have a ListFragment that returns a ListView. If there are no items in the list, I'd like to display an alternative TextView instead. Supposedly you can add a <em>TextView android:id="@android:id/empty"</em> element within the XML. </p>
  
  <p>But...</p>
  
  <p>Adding FrameLayout containing <em>both</em> the ListView and the TextView predictably gives me <em>"FrameLayout cannot be cast to ListView"</em>.</p>
  
  <p>I can't <em>just</em> add a TextView element either. <em>"The markup in the document following the root element must be wellformed."</em> </p>
  
  <p>And I can't switch to <em>View</em> instead of <em>ListView</em> because, well, it would no longer be a list. </p>
  
  <p>...how am I supposed to do this?</p>
  
  <p>Code:</p>
  
  <pre><code>    @Override
  public View onCreateView ( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) {
  
      adapter = new ArrayAdapter&lt;Project&gt; ( getActivity (), android.R.layout.simple_list_item_1 );
      arrayList = ProjectManager.getProjectList ( getActivity () );
      for ( Project p : arrayList ) {
          if ( p.getStatus () == Project.ONGOING ) {
              adapter.add ( p );
          }
      }
  
      ListView listView = ( ListView ) inflater.inflate ( R.layout.list, container, false );
      listView.setAdapter ( adapter );
  
      return listView;
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/list"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" /&gt;
  </code></pre>