Android EditText with word-wrap but no hard returns

后端 未结 3 1975
小鲜肉
小鲜肉 2020-12-31 11:07

If I set SingleLine=true on an EditText widget, I get a single-line edit control that doesn\'t allow hard returns to be inserted by the user (clicking Enter moves to the nex

3条回答
  •  -上瘾入骨i
    2020-12-31 11:28

    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    //This will treat Enter as Done instead of new line:
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT); 
    
    And in XML:
    android:inputType="textMultiLine"
    

提交回复
热议问题