Android 如何使TextView中的文本在布局XML中不可读取?

Android 如何使TextView中的文本在布局XML中不可读取?,android,android-layout,textview,tablerow,Android,Android Layout,Textview,Tablerow,我有不同的表格行,每一行都包含一些信息文本,这些信息文本不应该是可点击的,也不应该是可选择的。但是,当我在模拟器中运行它时,文本总是可以单击的 这意味着,当我点击任何文本块时,它的颜色变为深灰色。我不想让它改变。我希望它什么也不做 当然,我可以将深灰色设置为文本颜色,这样用户就不会看到他点击了任何东西,但这不是我想要的 正如您在示例中看到的,我已经尝试了不同的属性,但是没有任何帮助。此外,我实际上必须设置什么不可点击,TableRow还是TableRow中的TextView 以下是一个例子: &

我有不同的表格行,每一行都包含一些信息文本,这些信息文本不应该是可点击的,也不应该是可选择的。但是,当我在模拟器中运行它时,文本总是可以单击的

这意味着,当我点击任何文本块时,它的颜色变为深灰色。我不想让它改变。我希望它什么也不做

当然,我可以将深灰色设置为文本颜色,这样用户就不会看到他点击了任何东西,但这不是我想要的

正如您在示例中看到的,我已经尝试了不同的属性,但是没有任何帮助。此外,我实际上必须设置什么不可点击,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>

您需要设置以下属性:

         android:clickable="false"
         android:linksClickable="false"
         android:focusable="false"
         android:focusableInTouchMode="false"

在您的textview元素中。现在,您只是禁用行,而不是行中的单个元素。

我找到了解决方案,当我将android:longClickable=“false”添加到TextView时,它可以工作。我只需要TextView中的这两个设置:

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

不需要在TableRow中进行设置。

是整个TableRow被更改为深灰色,还是只有文本中的文本被更改为暗灰色?我的疑问是,如果我们为TableRow阻止了所有内容,那么TableRow中的textView怎么会发生单击事件?呃,什么?为什么这甚至是一个问题?你试过确认这个问题吗?实际上@Bevor已经试过他提到的不同属性,他最后的文本视图显示他添加了你上面提到的所有属性。@Kurtis:查看最后的文本视图。