Home > front end >  Detect that EditText's Input is Number and do not allow the user type other sort of characters
Detect that EditText's Input is Number and do not allow the user type other sort of characters

Time:09-16

Hi there i was developing an app then i got into how can my app detect the input of edit text. For example after putting something in edittext , i want only Digit inputs not characters.

public class percentInputActivity extends AppCompatActivity {
    EditText correctInputText = (EditText) findViewById(R.id.inputCorrect);
    Button calButton = (Button) findViewById(R.id.calButton);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_percent_input);



    }}

CodePudding user response:

In the design panel of your window, choose your EditText and search for inputType attribute, from there you can choose exactly what you are expecting to receive, in your case you should choose number.

inputType

feel free also to check the other options.

  • Related