MikeT
MikeT

Reputation: 404

Android EditText append not seeing multiline text

I have a EditText which I disabled the keyboard from popping up. And a set of buttons to enter text into the EditText with. The idea is to click a button -> enter some text into the text field.

I append the text to be input and the problem is that it just keeps appending on the same line. How can I get the text to go to a new line once we reached the end of the bounds of the text field (like how the default keyboard does)?

my edit text looks something like this:

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:inputType="textMultiLine" 
        android:scrollHorizontally="false" 
        android:gravity="top|left" 
        android:cursorVisible="true" 
        android:lines="10">

Upvotes: 2

Views: 1376

Answers (2)

MikeT
MikeT

Reputation: 404

Ok I found what the problem is. I had disabled the softkeyboard by doing this:

    Etext = (EditText) findViewById(R.id.editText1);
    Etext.setInputType(0); 

I found that when I didn't disable the softkeyboard, the multi line worked just fine.

Solution was to NOT setInputType(0) and set editable=false and inputType=none in the layout - now no keyboard shows and also text wraps to new line.

        android:inputType="none"
        android:editable="false"

Upvotes: 1

Padma Kumar
Padma Kumar

Reputation: 20041

//remove this

 android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"

Upvotes: 0

Related Questions