Android: Setting EditText Max Chars per Line?

前端 未结 7 1657
再見小時候
再見小時候 2021-01-15 02:29

Is there any way to set a maximum of Chars to a line in an EditText Field? I tried it with a TextWatcher, But I cant really do what I want.

<
7条回答
  •  暖寄归人
    2021-01-15 03:07

    As you can see in above answers , you cant limit line length in edit text. But you can use text watcher that you mentioned to detect any changes in text. The override methods are self-explanatory in text watcher. Just make sure you dont edit, ie add text to the associated view when using text watcher. It will go in a recursive loop.

提交回复
热议问题