android - TextView value from Row Position ListView -
what have setup listview has 1 textview , 2 buttons. trying when first button clicked, want give me value in textview.
i have spent lot of time looking can't find answer work. have code in onclick button method:
// position of button int position = pendinglist.getpositionforview((view) view.getparent()); //extract text string pendingusertext = pendingusers.get(position).get(r.id.name);
something note use arraylist map populate listview , simple adapter. when this, problem when try toast.make , pass "pendingusertext" through it, null value. appreciated!
here xml file
<textview android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingbottom="2dip" android:paddingtop="6dip" android:textsize="16sp" android:textstyle="bold" android:height="30dp" /> <button android:id="@+id/addbutton" android:layout_height="fill_parent" android:layout_width="wrap_content" android:text="accept" android:layout_aligntop="@+id/name" android:layout_centerhorizontal="true" android:background="#3366cc" android:textcolor="#b0e0e6" android:layout_alignbottom="@+id/name" android:clickable="true" android:bottomleftradius="8dp" android:bottomrightradius="8dp" android:topleftradius="8dp" android:toprightradius="8dp" android:onclick="addbuttonclicked" /> <button android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/declinebutton" android:text="decline" android:textcolor="#b0e0e6" android:background="#3366cc" android:bottomleftradius="8dp" android:bottomrightradius="8dp" android:topleftradius="8dp" android:toprightradius="8dp" android:layout_aligntop="@+id/name" android:layout_alignright="@+id/name" android:layout_alignend="@+id/name" android:layout_alignbottom="@+id/name" android:clickable="true" />'
here listadapter
istview list = (listview) findviewbyid(r.id.friendslistview); listadapter adapter = new simpleadapter( friendsactivity.this, pendingusers, r.layout.list_item, new string[] {tag_fromuser}, new int[] { r.id.name}); list.setadapter(adapter);
found answer.
relativelayout vwparentrow = (relativelayout)view.getparent(); textview pending =(textview)vwparentrow.findviewbyid(r.id.name);
for needs it.
Comments
Post a Comment