Récupérer en mémoire un élément d'un TextView
Bonjour,
J'ai un listview peuplé avec un simpleadapter
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#D5EFE6"
android:layout_weight="2"
android:drawSelectorOnTop="false"
android:fastScrollEnabled="True"
android:cacheColorHint="#00000000"
>
</ListView>
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#D5EFE6"
android:textColor="#000000"
android:text="Pas de données pour cette période."
/>
</LinearLayout> |
chaque élément contient en fait 4 textview.
j'aimerais, sur clic de l'élement de la liste récupérer le texte de l'élement 2 par exemple.
alors j'ai essayé de créer cet évenement :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
ListView lv1 = (ListView)findViewById(id.list);
lv1.setAdapter(adapter);
lv1.setOnItemClickListener( new OnItemClickListener()
{
@Override
public void onItemClick( AdapterView lv1, View view,
int pos, long id )
{
TextView textView = (TextView)lv1.getItemAtPosition(pos);
textView.getText();
}
}); |
mais malgré le fait que, au début, il prenne bien en compte la pos et l'id du clic et que le textview est bien non null le gettext fait planter.
je préciser que je suis débutant, un peu d'indulgence svp...
merci :)