Java 如何在表格行内的文本视图中单击

Java 如何在表格行内的文本视图中单击,java,android,click-through,Java,Android,Click Through,我的第一个问题在这里! 我需要一些关于点击我的文本视图的帮助。 它们被插入到动态添加到TableLayout的TableRow中。它们几乎占据了TableRows的所有空间(减去填充),正因为如此,我无法做到这一点,所以TableRows ClickListener注册了单击,而不是文本视图。只有单击行的边缘(同样,填充)时,它才起作用 下面是要插入到预定义TableLayout中的行的XML,其中包含我需要单击的TextView <?xml version="1.0" encoding=

我的第一个问题在这里! 我需要一些关于点击我的文本视图的帮助。 它们被插入到动态添加到TableLayout的TableRow中。它们几乎占据了TableRows的所有空间(减去填充),正因为如此,我无法做到这一点,所以TableRows ClickListener注册了单击,而不是文本视图。只有单击行的边缘(同样,填充)时,它才起作用

下面是要插入到预定义TableLayout中的行的XML,其中包含我需要单击的TextView

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:clickable="true"
 >

<TextView
    android:id="@+id/contactId"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

<TextView
    android:id="@+id/contactEntryLastName"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textColor="@color/black"
    android:textIsSelectable="true"
    android:background="@android:color/transparent"

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

<TextView
    android:id="@+id/contactEntryFirstName"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textColor="@color/black"
    android:textIsSelectable="true"
    android:background="@android:color/transparent" 

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

</TableRow>

我一直在寻找解决方案,我找到的唯一一个解决方案据说是将所有那些“可点击”和可聚焦属性设置为false,但这些都不起作用

真的应该有一个简单的解决办法,对吧

试试这个

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:descendantFocusability="blocksDescendants" >

<TextView
    android:id="@+id/contactId"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

<TextView
    android:id="@+id/contactEntryLastName"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textColor="@color/black"
    android:textIsSelectable="true"
    android:background="@android:color/transparent"

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

<TextView
    android:id="@+id/contactEntryFirstName"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textColor="@color/black"
    android:textIsSelectable="true"
    android:background="@android:color/transparent" 

    android:clickable="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false" />

</TableRow>

没有,这没有帮助:(我也试过“前代”和“后代”,但都不起作用。奇怪的是,这样的事情竟如此复杂。