'EditText not editable after ListView is put into LinearLayout
I'm building a simple To-Do app. I've put EditText and then created LinearLayout above. But after I put ListView into LinearLayout, EditText stops working meaning that I can't press on the plain text and type. If I delete ListView, EditText is working.
Any suggestions? What is not right here?
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MainActivity">
<EditText
android:id="@+id/newTaskEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/button"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginBottom="3dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="1.5dp"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:background="#3F51B5"
app:layout_constraintBottom_toTopOf="@+id/newTaskEditText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:layout_width="409dp"
android:layout_height="678dp"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
I'm quite new to Android Development. Thanks in advance!
I've got Constraint Layout in which I put EditText. In this same layout I put LinearLayout, in which I put ListView, and after that action EditText stops being editable, and I have no idea why.
I also want to add that I did all that using the full YouTube tutorial on that dated year 2019. So it shouldn't be an issue, should it?
UPD: The problem has been fixed changing ListView to androidx.recyclerview.widget.RecyclerView, but I still want to know why the problem was there in the first place.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
