Directly change the content type integer of the text view, without modifying any other state.
Related XML Attributes: android:inputType
1. Add a EditText in the main.xml file or Instantiate a new EditText object named myEditText.
2. Add the below line to the import section.
import android.text.InputType;
2. In the MainActivity.java file, add the code below. This will set the soft keyboard displayed to be numeric.
myEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
3. Compile and run!
4. Other InputType options are list on this page: developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER
Resources:
http://developer.android.com/reference/android/widget/TextView.html#setRawInputType(int)developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER
http://stackoverflow.com/questions/9933574/edittext-setinputtype-vs-setrawinputtype