Java – Android programming – Multi-line EditText in the ListView

Android programming – Multi-line EditText in the ListView… here is a solution to the problem.

Android programming – Multi-line EditText in the ListView

I have a ListView where each row contains a TextView and an EditText. I found that I can’t get multiple lines using this EditText. No matter what I type, the string doesn’t wrap to the next line. In addition, the soft keyboard does not display the “Enter key” — it displays the “Done” key.

If I copy block outside of the ListView, it works like multiple lines. But it doesn’t work in the ListView.

I would appreciate it if someone could provide some help. Thanks!

My ListView row has this layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView 
    android:layout_width="140dp"
    android:layout_height="fill_parent"
    android:gravity="center_vertical|right"
    android:paddingLeft="3dp"
    android:paddingRight="5dp" 
    android:id="@+id/listitem_maindesc"
    android:textColor="#000000"
    android:textSize="16sp"></TextView>

<EditText
    android:id="@+id/listitem_entry"        
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:singleLine="false"
    android:lines="3"
    android:minLines="3"
    android:inputType="textMultiLine"       
    />

</LinearLayout>

Solution

I fixed a problem with the same one but changed my OnKeyListener to return false.

Related Problems and Solutions