2011-07-02 4 views
3

J'ai un ListView, dans lequel chaque ligne contient un TextView et un EditText. Je trouve que je ne peux pas obtenir multiline avec ce EditText. Quoi que je tape, la chaîne ne passe pas à la ligne suivante. De plus, le clavier logiciel n'affiche pas la touche "Enter" - il affiche à la place une touche "Done".Programmation Android - Multiline EditText dans ListView

Si je copie le bloc à l'extérieur ListView, il fonctionne comme multiline. Mais cela ne fonctionne pas dans ListView.

J'apprécierai si quelqu'un peut faire la lumière. Je vous remercie!

Ma ligne ListView a cette mise en page:

<?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> 

Répondre

0

Je résolu un problème égal à cela, mais en changeant mon OnKeyListener pour revenir faux.

0

Je pense qu'un problème est lié à votre fichier XML car vous n'avez pas défini dans xml que editText ne doit pas être placé au-dessus de textView, il prendra donc une longueur maximale.

essayez ceci:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"         
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 
    <TextView 
     android:layout_width="140dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:paddingLeft="3dp" 
     android:paddingRight="5dp" 
     android:id="@+id/listitem_maindesc" 
     android:textColor="#000000" 
     android:layout_centerVertical="true" 
     android:textSize="16sp" > </TextView> 

    <EditText 
     android:id="@+id/listitem_entry"   
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="16sp" 
     android:singleLine="false" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="" 
     android:layout_centerVertical="true" 
     android:inputType="textMultiLine"  /> 
</RelativeLayout>