【发布时间】:2013-08-12 14:52:45
【问题描述】:
我有一个 a 行 LIstView 项目的布局,如下所示:
<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>
当用户点击删除按钮(在 myClickHandler() 方法中)时,我想获取 TextView 的文本,
使用此代码:
RelativeLayout vwParentRow = (RelativeLayout)v.getParent();
我得到了Button(RelativeLayout) 的父级,但不知道如何在Button 的父级中获取TextView 的文本
我该怎么做?
谢谢
【问题讨论】:
标签: android textview android-textattributes