2013-02-05 62 views

回答

3

EditTextmaxLength属性。只要将它设置为1

<EditText 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:maxLength="1"/> 
6

从布局添加属性

android:maxLength="1" 

或代码

TextEdit te = findViewById(...); 
te.setFilters(new InputFilter[] { new InputFilter.LengthFilter(1) }) 
相关问题