2013-02-05 60 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) }) 
相關問題