android - Get text of TextView from a row of ListView -
i have layout row of listview items this:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="right" android:descendantfocusability="afterdescendants" android:gravity="right" android:orientation="vertical" > <textview android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="right" android:gravity="right" android:textsize="40sp" android:focusableintouchmode="false" android:clickable="false" android:focusable="false" /> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/btn_background" > <button android:id="@+id/share_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:layout_margintop="2dp" android:background="@drawable/delete_btn" android:drawableright="@drawable/delete" android:paddingbottom="3dp" android:paddingtop="2dp" android:text="share" android:onclick="myclickhandler" /> </relativelayout> </linearlayout>
and want text of textview when user click on delete button(in myclickhandler() method),
with code:
relativelayout vwparentrow = (relativelayout)v.getparent();
i parent of button(relativelayout), don't know how text of textview in parent of parent of button
how can this?
thanks
try in myclickhandler()
method
relativelayout vwparentrow = (relativelayout)v.getparent(); linearlayout vwgrandparentrow = (linearlayout)vwparentrow.getparent(); textview yourtv=(textview)vwgrandparentrow.findviewbyid(r.id.label); log.i("text",yourtv.gettext().tostring());
Comments
Post a Comment