Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android software keyboard switch between numeric and alphabetic programmatically

I have an EditText with inputMode = text. By default software keyboard is shown as alphabetical and user have to switch it to numeric by pressing specific key (like "123").

Having text inputMode is it possible to show numeric keyboard by default instead of alphabetic?

I need both alphabetic and numeric. But numeric is used more often then alphabetic so i search for way to switch mode programmatically.

like image 715
user655419 Avatar asked Jan 24 '12 14:01

user655419


2 Answers

Just set it with the normal setter:

    EditText editText = (EditText) findViewById(R.id.edittext);
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    // or 
    editText.setInputType(InputType.TYPE_CLASS_TEXT);
like image 155
Mark Avatar answered Oct 20 '22 15:10

Mark


I find the answer a day, finally I found this and its work.

android:inputType="textVisiblePassword"

source

like image 28
Zainal Fahrudin Avatar answered Oct 20 '22 16:10

Zainal Fahrudin