Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make text visible in an android ListView
    text
    copied!<p>I am working on listview, I want to make the text visible that is given to it in the textview in xml file. The list items i have added in list is showing correctly (visible ) but not the text. I want that text visible too need help for it.</p> <p><img src="https://i.stack.imgur.com/Go7tI.png" alt="enter image description here"></p> <p>Xml file</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="wrap_content" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/id" android:layout_width="fill_parent" android:layout_height="wrap_content" android:visibility="gone" /&gt; &lt;TextView android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="6dip" android:paddingLeft="6dip" android:text="Name:" android:visibility="visible" android:textSize="17sp" android:textStyle="bold" /&gt; &lt;TextView android:id="@+id/gender" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="6dip" android:paddingTop="6dip" android:text="Gender:" android:textColor="#FF00FF" android:textSize="17sp" android:textStyle="bold" android:visibility="visible" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Java code: Putting data into adapter</p> <pre><code>if (success == 1) { products = json.getJSONArray(TAG_PRODUCTS); for (int i = 0; i &lt; products.length(); i++) { JSONObject c = products.getJSONObject(i); String id = c.getString(TAG_PID); String name = c.getString(TAG_NAME); String gender = c.getString(TAG_GENDER); HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put(TAG_ID, id); map.put(TAG_NAME, name); map.put(TAG_GENDER, gender); productsList.add(map); } public void run() { ListAdapter adapter = new SimpleAdapter( AllPersonActivity.this, productsList, R.layout.list_item, new String[] { TAG_ID, TAG_NAME, TAG_GENDER}, new int[] { R.id.pid, R.id.name, R.id.gender }); // updating listview setListAdapter(adapter); } }); </code></pre>
 

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