Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try it this way...</p> <p>First a simple activity_main.xml layout</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" &gt; &lt;ListView android:id="@+id/root_list" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" /&gt; &lt;ViewStub android:id="@+id/root_empty" android:layout_width="match_parent" android:layout_height="match_parent" android:layout="@layout/empty_view" android:visibility="gone" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and from your MainActivity.java:</p> <pre><code>public class MainActivity extends Activity { ListView mListView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.mListView = (ListView) findViewById(R.id.root_list); mListView.setEmptyView(findViewById(R.id.root_empty)); mListView.setAdapter(null); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <p>Whatever is placed in <code>R.layout.empty_view</code> will appear whenever the adapter is null or isEmpty returns true.</p> <p>I used this for the empty_view.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:id="@+id/empty_view" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" android:background="@color/gray" android:gravity="center" android:text="@string/list_empty" android:textColor="@color/white" android:textSize="24sp" /&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload