user934820 February 2016

how to check if edittext is single line android

I am making a custom android keyboard. I want to make it sure that when user press enter key proper EditorAction took place. Therefore I want to know is there any way to check if edittext is single line or not? Or is there any way to check min and max lines of editext?

Answers


beef February 2016

In your onStartInput(EditorInfo info) and onStartInputView(EditorInfo info) callbacks EditorInfo is passed in.

To check if it's a multiline you can do:

if (0 != (info.inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE)) {
   //This is multiline text field
}

See TYPE_TEXT_FLAG_MULTI_LINE

Post Status

Asked in February 2016
Viewed 1,741 times
Voted 7
Answered 1 times

Search




Leave an answer