Comment développer et réduire un élément dans la vue liste

Je suis assez nouveau pour android. Je veux mettre en œuvre une vue de liste. Il contient certains éléments de liste et quand on clique dessus, ils doivent développer montrant plus d'informations. Mais je n'arrive pas à trouver un moyen de le faire

Voici mon activity_main.xml

<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" >

    <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" >
    </ListView>

</RelativeLayout>

listview.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <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" />

    <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" />
</RelativeLayout>

Je veux remplir le textview2 pour afficher plus d'informations. Ci-dessous mon main_activity.java

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<String> adapter = new ArrayAdapter<String>(this,
                R.layout.listview, R.id.textView1, titles);
        list.setAdapter(adapter);
    }

Strings.xml

<string name="app_name">ListView</string>
<string name="hello_world">Hello world!</string>
<string-array name="text_info">
    <item>Tutorial 1</item>
    <item>Tutorial 2</item>
    <item>Tutorial 3</item>
    <item>Tutorial 4</item>
    <item>Tutorial 5</item>
    <item>Tutorial 6</item>
    <item>Tutorial 7</item>
</string-array>

<string-array name="text_desc">
    <item>Tutorial 1</item>
    <item>Tutorial 2</item>
    <item>Tutorial 3</item>
    <item>Tutorial 4</item>
    <item>Tutorial 5</item>
    <item>Tutorial 6</item>
    <item>Tutorial 7</item>
</string-array>

<string name="action_settings">Settings</string>

Des suggestions sur la façon de faire cela?

Comment développer et réduire un élément dans la vue liste

android:drawableLeft="@drawable/expand_icon" Je ne vois que cela pour l'instant. Et je le vois dans deux états dans l'image. Quel type d'icône est-ce? Avez-vous ajouté du code pour changer d'état et cliquez sur?

OriginalL'auteur Itapu Vinay | 2014-09-17