7

Android layout.xml で選択した文字セット (例: A または B または C または D) のみを入力できるユーザーを制限する方法はありますか?

4

4 に答える 4

12

digits属性を使用すると、渡された文字のみdigitsが EditText で許可されます。

android:digits="abc123"

はい、「数字」は誤解を招く名前です。文字や記号も受け入れます。

于 2012-11-17T17:45:49.567 に答える
2

inputType次の属性を使用できます。

   <EditText android:id="@+id/edit_text_id"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:inputType="number" />

android:inputType編集テキストの属性の可能な値は次のとおりです。none, text, textCapCharacters, textCapWords, textCapSentences, textAutoCorrect, textAutoComplete, textMultiLine, textImeMultiLine, textNoSuggestions, textUri, textEmailAddress, textEmailSubject, textShortMessage, textLongMessage, textPersonName, textPostalAddress, textPassword, textVisiblePassword, textWebEditText, textFilter, textPhonetic, textWebEmailAddress, textWebPassword, number, numberSigned, numberDecimal, numberPassword, phone, datetime, date, time

于 2012-11-17T18:32:25.803 に答える
0

これandroid:digitにより、EditText に入力したい数字とアルファベットのみが許可されます。

<EditText 
      android:inputType="text" 
      android:digits="0123456789*qwertzuiopasdfghjklyxcvbnm,_,-" 
      android:hint="Only letters, digits, _ and - allowed"
    />
于 2015-11-17T06:00:19.880 に答える
0

このように EditText フィールドを設定できます...

<EditText 
  android:inputType="text" 
  android:digits="THE SELECTED CHARACTERS THAT USERS ARE ALLOWED TO TYPE" 
/>

ユーザーが android:digits に入力できる選択された文字 (A、B、C、および D) をリストすることで、ユーザーが入力できる文字を制限しています。これは、検索を通じて学んだ最も簡単な方法です。

于 2016-02-22T04:31:32.610 に答える