Reputation: 167
I have edit text view in my layout like below. I am able to set digits to accept but I want set limit to accept between two numbers like 1 to 100 from java. I am not able to get idea how I can achieve this. My edittext is like below
<EditText
android:id="@+id/userInputDialog"
android:layout_marginTop="20dp"
android:layout_below="@+id/dialogueError"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="120"
android:textStyle="bold"
android:digits="0123456789"
android:textColorHint="@color/toolbar_text"
android:textColor="@color/toolbar_text"
android:inputType="number" />
Let me know if anyone can help me here for same. Thanks!
Upvotes: 0
Views: 93
Reputation: 1093
You have
android:maxLength="2"
To set it to only 2 chars length. You can also use
android:inputType="number"
For numbers only
Upvotes: 1