I have an editText that is set so that a user can only enter an integer value. The value is then sent to an API. The problem is that the server get's overloaded if the value is too high (Heroku problems). I was wondering if there was a way to actually limit the value that was able to be entered into the editText. For example the user can only enter a value between 1-800.
Obvioulsy I cant limit the value by number of figures, for example 3 figures, as that would allow for a value of up to 999.
There is another question open for this, however the answers in that Q dont seem to come up with one elegant solution, instead an amalgamation of different pieces of buggy code.
Here is the current MainActivity and xml for the editText.
activity_main.xml
<EditText
android:id="@+id/editText2"
android:layout_width="274dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="278dp"
android:ems="10"
android:hint="Enter number of tweets..."
android:inputType="number" />
mainActivity.Java
EditText editText2 = findViewById(R.id.editText2);
String tweetNo = editText2.getText().toString();
With an onclicklistener for the button that draws the data from the editText as well.