Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to forbid the first number in a EditText to be "0"

Tags:

People also ask

How do I make EditText disabled?

To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.

What does an empty EditText return?

It returns CharSequence whose contents may be empty. CharSequence is an object reference to some class that implements the interface.

How do I change my EditText value?

Set the Text of Android EditText In android, we can set the text of EditText control either while declaring it in Layout file or by using setText() method in Activity file. Following is the example to set the text of TextView control while declaring it in XML Layout file.


Hi I just want to know if it is possible to forbid the first number that the user can enter to be "0".

<EditText
        android:id="@+id/editText1"
        android:layout_width="50dp"
        android:layout_height="35dp"  
        android:layout_marginBottom="2dp" 
        android:maxLength="2"
        android:inputType="number"
        android:digits="123456789">
        <requestFocus />
    </EditText>

Using this code however prevents the user from entering "0" at all but I want just the first digit not to be "0"