title: How to expand and collapse an item in listview
body: <p>I am pretty new to android. I want to implement a list view. It contains some list items and when they are clicked, they should expand showing more information. But I unable to find a way to do that</p>
  
  <p>Here is my <code>activity_main.xml</code></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="match_parent" &gt;
  
      &lt;ListView
          android:id="@+id/listview1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:clickable="True"
          android:layout_alignParentTop="true"
          android:divider="#000"
          android:dividerHeight="0.5dp"
          android:padding="7dp" &gt;
      &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><code>listview.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginLeft="23dp"
          android:layout_marginTop="20dp"
          android:drawableLeft="@drawable/expand_icon"
          android:drawablePadding="10dp"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView1"
          android:layout_below="@+id/textView1"
          android:visibility="gone" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I want to populate the <code>textview2</code> to show more info. Below is my <code>main_activity.java</code></p>
  
  <pre><code>public class MainActivity extends Activity {
  
      ListView list;
      String[] titles;
      String[] desc;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Resources res = getResources();
          list = (ListView) findViewById(R.id.listview1);
          titles = res.getStringArray(R.array.text_info);
          desc = res.getStringArray(R.array.text_desc);
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                  R.layout.listview, R.id.textView1, titles);
          list.setAdapter(adapter);
      }
  </code></pre>
  
  <p>Strings.xml</p>
  
  <p>
  </p>
  
  <pre><code>&lt;string name="app_name"&gt;ListView&lt;/string&gt;
  &lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
  &lt;string-array name="text_info"&gt;
      &lt;item&gt;Tutorial 1&lt;/item&gt;
      &lt;item&gt;Tutorial 2&lt;/item&gt;
      &lt;item&gt;Tutorial 3&lt;/item&gt;
      &lt;item&gt;Tutorial 4&lt;/item&gt;
      &lt;item&gt;Tutorial 5&lt;/item&gt;
      &lt;item&gt;Tutorial 6&lt;/item&gt;
      &lt;item&gt;Tutorial 7&lt;/item&gt;
  &lt;/string-array&gt;
  
  &lt;string-array name="text_desc"&gt;
      &lt;item&gt;Tutorial 1&lt;/item&gt;
      &lt;item&gt;Tutorial 2&lt;/item&gt;
      &lt;item&gt;Tutorial 3&lt;/item&gt;
      &lt;item&gt;Tutorial 4&lt;/item&gt;
      &lt;item&gt;Tutorial 5&lt;/item&gt;
      &lt;item&gt;Tutorial 6&lt;/item&gt;
      &lt;item&gt;Tutorial 7&lt;/item&gt;
  &lt;/string-array&gt;
  
  &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any suggestions on how to do this?</p>
  
  <p><img src="https://i.stack.imgur.com/dU80e.png" alt="enter image description here"></p>