How to insert the mobile number on an android application using EditText

tutorial and example
tutorial and example

Number Insertion in android application:

Sometimes while dealing with numbers, we don’t want to insert any string inside an number so, we premiliary define an EditText so we externally specify an EditText attribute as android:inputType=”number”  After specifying this attribute in the EditText, it will be used only to insert a number.

Step 1: Create a brand new android project.

Step 2: Go to the xml file and select design.

Step 3: Under the text option, find an option named as number.

Step 4: Drag and drop the number to your preview.

Step 5: After dragging the Number text, your xml part will look like this:

After the step 5, your front end designing is completed.

Step 6:  Insert the following code in you Main Activity file:

import android.widget.EditText;

Step 7: Insert the following code in your MainActivity class:

private EditText number;

Step 8: Inside the onCreate method of your MainActivity class, insert the following code:

number=findViewById(R.id.editText);
String num=number.getText().toString();

This will initialize the number instance.

Step 9: In the final step, you can use the String number to get the number inserted by the user.

Developer may check the number entered by the user against the number in his database via num String.

I would suggest you to take a button to insert the number from the user.

Insert the following code on your onCreate method inside the

MainActivity.java file: