Wednesday, December 22, 2010

[android-developers] How to update one of views(setText, setImage) in item already added on ListView

Hi, all

* I have a ListView that using my layout document, to simplest, it
goes like this ...
<!-- itemraw.xml -->
<LinearLayout id="ll_parent" orient="vertical">
<TextView id="tv_1" text="hello_1"/>
<TextView id="tv_2" text="hello_2" />
<TextView id="tv_3" text="hello_3" />
</ LinearLayout>

* then I populate the items to the ListView...
ListView lv = (ListView)findViewById(R.id.mylv);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
R.layout.itemraw, R.id.tv_1, m_MyStringArray);
lv.setAdapter(aa);

* OK, the item is really populated like I think. Now I'd like to do
setText() to one of the TextView of one of ListView item...
LinearLayout ll = (LinearLayout)aa.getView(0, null, null);
TextView tv = (TextView)ll.findViewById(R.id.tv_3);
tv.setText("HAHAHAHAHA");

* Just like the program code, i set 3rd TextView with text "HAHAHAHA"
of first item, but nothing happened.

* My question is, an item has been already added to a ListView, can I
still update the UI?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment