title: Setting a layout to use as empty view for a ListView in case adapter has zero items in a Activity
body: <p>How to use a layout as empty view for a listview when the adapter has zero elements?</p>
  
  <p>setEmptyView is not working with this code : </p>
  
  <pre><code>public class ZeroItemListActivity extends Activity {
      private ArrayList&lt;String&gt; listItems=new ArrayList&lt;String&gt;();
      private ListView mMyListView;
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          mMyListView=(ListView) findViewById(R.id.MyListView);
          mMyListView.setAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,listItems));
          LayoutInflater inflator=getLayoutInflater();
          View emptyView=inflator.inflate(R.layout.empty_list_item, null);
          //Empty view is set here
          mMyListView.setEmptyView(emptyView);
      }
      public void addItem(View v){
          listItems.add("list Item");
          mMyListView.invalidate();
      }
  }
  </code></pre>
  
  <p>Layouts used : empty_list_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;
      &lt;Button android:id="@+id/Button01" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="Empty List,Click to add items"&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;TextView android:layout_width="fill_parent"
          android:layout_height="wrap_content" android:text="@string/hello" /&gt;
      &lt;ListView android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:id="@+id/MyListView"&gt;&lt;/ListView&gt;
      &lt;Button android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:id="@+id/AddItemsButton"
          android:text="Add Items" android:onClick="addItem"&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>