Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>Use RelativeLayout</p></li> <li><p>Add your emptyList view first</p></li> <li><p>Add you listView (emptyList must be right behind the listview)</p></li> <li><p>If you got 0 items from json, set the visibility of listView to View.INVISIBLE.</p></li> </ol> <p><strong>Edit:</strong></p> <p>Ok, you need to change your XML a little bit.</p> <p>enclose emptyList and list inside a RelativeLayout as follow.</p> <pre><code>&lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" &gt; &lt;TextView android:id="@+id/emptyList" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="There is no item" android:textSize="25sp" /&gt; &lt;ListView android:id="@+id/list" android:background="@android:color/white" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>To show empty text, set listView visibility to GONE. Here is sample output on my side. First with listView visibility Visible and 2nd is with listview visibility GONE</p> <p><img src="https://i.stack.imgur.com/TOXuU.png" alt=""><img src="https://i.stack.imgur.com/odAGM.png" alt=" "></p> <p>Here if your full updated xml code.</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;RelativeLayout android:layout_width="match_parent" android:layout_height="337dp" android:layout_gravity="center" android:layout_weight="0.74" &gt; &lt;TextView android:id="@+id/emptyList" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="There is no item" android:textSize="25sp" /&gt; &lt;ListView android:id="@+id/list" android:background="@android:color/white" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; &lt;!-- end of listview --&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>And in code.</p> <pre><code>if (container == null) { lv.setVisibility(View.INVISIBLE); } </code></pre> <p>Hope it will be useful.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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