Note that there are some explanatory texts on larger screens.

plurals
  1. POsetEmptyView on ListView not working
    primarykey
    data
    text
    <p>I'm trying to set empty view when the listView is empty. This is my full XML Layout :</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="fill_parent" android:layout_height="fill_parent" android:background="@drawable/fondgris" android:orientation="vertical" &gt; &lt;!-- Header Starts --&gt; &lt;RelativeLayout android:id="@+id/head" android:layout_width="fill_parent" android:layout_height="35sp" android:background="@layout/header_gradient" android:paddingBottom="5dip" android:paddingTop="5dip" &gt; &lt;TextView android:id="@+id/activity" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_alignParentLeft="true" android:layout_centerInParent="true" android:layout_marginLeft="5dp" android:gravity="center_vertical" android:scaleType="center" android:text="List of projects" android:textColor="#ffffff" android:textSize="13sp" android:textStyle="bold" android:tint="#0E5EC7" /&gt; &lt;ImageButton android:id="@+id/logout" android:layout_width="30dp" android:layout_height="35dp " android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="0dp" android:background="@android:color/transparent" android:onClick="logout" android:scaleType="center" android:src="@drawable/sortie" android:tint="#FFFFFF" &gt; &lt;/ImageButton&gt; &lt;ImageButton android:id="@+id/home" android:layout_width="35dp" android:layout_height="35dp " android:layout_centerVertical="true" android:layout_toLeftOf="@id/logout" android:background="@android:color/transparent" android:onClick="home" android:scaleType="center" android:src="@drawable/home" &gt; &lt;/ImageButton&gt; &lt;ImageButton android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="35dp " android:layout_centerVertical="true" android:layout_toLeftOf="@id/home" android:background="@android:color/transparent" android:onClick="back" android:scaleType="center" android:src="@drawable/back" android:tint="#FFFFFF" &gt; &lt;/ImageButton&gt; &lt;/RelativeLayout&gt; &lt;!-- Editext and ImageView for Search --&gt; &lt;RelativeLayout android:id="@+id/linearLayout2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;EditText android:id="@+id/inputSearch" android:layout_width="150dp" android:layout_height="35dp" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/bnSearch" android:hint="Search..." android:inputType="textVisiblePassword" android:textSize="12sp" /&gt; &lt;ImageButton android:id="@+id/bnSearch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/inputSearch" android:layout_centerInParent="true" android:layout_toLeftOf="@+id/bnClear" android:background="@android:color/transparent" android:src="@drawable/search" /&gt; &lt;ImageButton android:id="@+id/bnClear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/inputSearch" android:layout_centerInParent="true" android:layout_marginRight="3dip" android:background="@android:color/transparent" android:onClick="ClearSearch" android:src="@drawable/cancel" /&gt; &lt;Button android:id="@+id/imageButtonAddProject" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_centerInParent="true" android:drawableLeft="@drawable/add" android:onClick="addProject" android:text=" Add Project" android:textColor="@color/text_color" android:textSize="12sp" /&gt; &lt;/RelativeLayout&gt; &lt;!-- List View --&gt; &lt;ListView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="337dp" android:layout_weight="0.74" &gt; &lt;/ListView&gt; &lt;TextView android:id="@+id/emptyList" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:text="Liste vide " android:textSize="12sp" /&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.04" android:orientation="horizontal" &gt; &lt;Button android:id="@+id/bnPrevious" android:layout_width="80dp" android:layout_height="35dp" android:layout_marginLeft="30dp" android:background="@android:color/transparent" android:text="&amp;lt;&amp;lt; Prev" android:textSize="12sp" /&gt; &lt;TextView android:id="@+id/page" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Page" android:textSize="12sp" /&gt; &lt;EditText android:id="@+id/editpage" android:layout_width="wrap_content" android:layout_height="35dp" android:textSize="12sp" /&gt; &lt;TextView android:id="@+id/of" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="of " android:textSize="12sp" /&gt; &lt;TextView android:id="@+id/nbpage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp" /&gt; &lt;Button android:id="@+id/bnNext" android:layout_width="80dp" android:layout_height="35dp" android:layout_marginRight="30dp" android:background="@android:color/transparent" android:text="Next &gt;&gt;" android:textSize="12sp" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>It has no effect, I did debugging and it enter in if part but without setting the list to empty, the list continue to appear ! I can't understand why, I appreciate your help.</p> <pre><code>final ProjectContainer container = gson.fromJson(resultat, ProjectContainer.class); final ListView lv = (ListView) findViewById(R.id.list); TextView emptyList = (TextView) findViewById(R.id.emptyList); // if list empty if (container == null) { lv.setEmptyView(emptyList); emptyList.setText("No Projects Found"); } </code></pre> <p>Thanks in advance.</p>
    singulars
    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.
 

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