Create a multiline EditText programmatically

android, android-edittext, multiline

Solution

This should do it

txt.setSingleLine(false);
txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);

Problem

I am trying to create a multiline EditText by code. This is what I use: ``` EditText txt = new EditText(this); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); txt.setLayoutParams(lp); txt.setSingleLine(false); txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); ``` But it is still in one single line.

Original source