我有不同的表行,每个表行都包含一些信息文本,这些文本不应该是可点击的,也不应该是可选择的。但是当我在模拟器中运行这个程序时,文本总是可以点击的。
这意味着,当我点击任何文本块时,它的颜色会变为深灰色。我不想改变。我要它什么也不做。
当然,我可以将深灰色设置为文本颜色,这样用户就不会看到他点击了任何东西,但这不是我想要的。
我已经尝试了不同的属性,正如你在示例中看到的,但是没有任何帮助。此外,我实际上需要在tablerow中设置不可单击的tablerow或textview,这是什么?
下面是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical|center_horizontal"
    >
    <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal">
    <TableLayout
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:stretchColumns="*"
            android:clickable="false">
        <TableRow
            android:layout_width="fill_parent"
            android:background="#777777"
            android:clickable="false">
            <TextView
                 android:id="@+id/heading"
                 android:text="This is the cool heading"
                 android:textColor="#FFFFFF"
                 android:layout_width="fill_parent"
                 android:textSize="14sp"
                 android:paddingLeft="5sp"
                 android:paddingRight="5sp"
                 android:paddingTop="2sp"
                 android:paddingBottom="2sp"
                 android:textStyle="bold"
                 android:clickable="false"
                 />
        </TableRow>
         <TableRow
             android:clickable="false"
             android:linksClickable="false"
             android:focusable="false"
             android:focusableInTouchMode="false">
            <TextView
                 android:text="This is example text. It should not be clickable, but it is."
                 android:textSize="14sp"
                 android:paddingLeft="5sp"
                 android:paddingRight="5sp"
                 android:paddingTop="2sp"
                 android:paddingBottom="2sp"
                 android:scrollHorizontally="false"
                 android:inputType="textMultiLine"
                 android:linksClickable="false"
                 android:clickable="false"
                 android:focusable="false"
                 android:focusableInTouchMode="false"
                 android:layout_width="0sp"
                 />
               </TableRow>
              </TableLayout>
              </ScrollView>
              </RelativeLayout>

最佳答案

我找到了解决方案,当我向textview添加android:longClickable="false"时,它就工作了。我只需要textview中的这两个设置:

android:longClickable="false"
android:clickable="false"

不需要TableRow中的设置。

07-24 09:49
查看更多