Answer the question
In order to leave comments, you need to log in
Why is ListView not clickable?
I created a ListView with my own adapter and layer. Launched, filled the sheet with elements, but they turned out to be non-clickable. The sheet's Clickable property is positive, the layer contains two TextViews and one Switch (clickable / non-clickable - it doesn't matter, I tried it anyway). How to fix it? System layers are not suitable, but they are all right.
Layer XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="9"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"></LinearLayout>
<TextView
android:id="@+id/todo_head"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_weight="3"
android:gravity="bottom"
android:text="Это всё"
android:textColor="@android:color/black" />
</LinearLayout>
<Switch
android:id="@+id/statement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="0dp"
android:layout_weight="1"
android:clickable="false"
android:gravity="right" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="22dp">
<TextView
android:id="@+id/todo_body"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:text="Будет выглядеть вот так"
android:textColor="@android:color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<!--столько layout'ов нужно для правильного расположения компонентов относительно друг друга-->
<ListView
android:id="@+id/list_todo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question