Android – how to make text in textview non clickable in layout XML?
I have different table rows. Each table contains some non clickable and non selectable information text. However, when I run it in the simulator, the text is always clickable
This means that when I click on any text block, its color will change to dark gray. I don't want it to change. I want it to do nothing
Of course, I can set dark gray as the text color so that the user won't see anything he clicks, but that's not what I want
I've tried different properties, which you can see in the example, but it doesn't help. In addition, what non clickable tablerow or textview in tablerow do I actually need to set?
Here is an example:
<?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>
resolvent:
I found a solution. It works when I add Android: longclickable = "false" to textview. I only need these two settings in textview:
android:longClickable="false"
android:clickable="false"
The setting in tablerow is not required