Note that there are some explanatory texts on larger screens.

plurals
  1. POFilling ListView out
    text
    copied!<p>I'm working on project and main layout contains ListView. I want to dynamically add subItems to <code>ListViewItem</code> View. My main layout is as follows :</p> <p>main_layout.xml</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="TextView"/&gt; &lt;ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>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="match_parent" android:layout_height="50dip" android:background="@android:color/transparent" &gt; &lt;/LinearLayout&gt; </code></pre> <p>And I want to add <code>TextView</code> to returned <code>view</code> in <code>getView</code> with following properties :</p> <ol> <li><strong>Height</strong> : fill_parent</li> <li><strong>Width</strong> : wrap_content</li> <li><p><strong>Text</strong> : Text View Item</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) this.M_context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.list_item, parent, false); return convertView; } </code></pre></li> </ol> <p><strong>Please note</strong> that, I want to dynamically add subItems to ListViewItem. You can suppose that, I have array of TextView and want to fill my listView using this Items. How can I do this scenario ? I can not find any result with searching on other threads and aslo Google. So, Could any one please help me to solve my problem ?</p> <p>Thanks in Advance :)</p>
 

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