Disable Enter in editText android

前端 未结 10 1668
别那么骄傲
别那么骄傲 2021-02-05 03:15

I have an EditText but I want only one line. I put lime this

1


        
10条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 03:43

    Please use

    android:singleLine="true"
    

    instead of

        1
        1
        1
    

    That single attribute is enough to make your EditText accept only one line of text and disable the enter button.

    UPDATE

    Don't worry about this comment,

    android:singleLine is deprecated it's not a good practice using it

    This attributed is officially supported and is not deprecated in any possible way. And it is also guaranteed that this will work in all devices and on all Android versions.

提交回复
热议问题