When I searched I got an answer but that didnt help me. Well. Now, in my manifest file I used with that particular activity like this: android:windowSoftInputMode="stateVisible" It works but shows only alpha keyboard! I want actually want numeric keyboard,please.
Asked
Active
Viewed 791 times
1
-
are you using any edittext on launcher activity? – Shadik Khan Mar 31 '15 at 15:29
-
Yes.Input is numeric. – user3144078 Mar 31 '15 at 15:38
-
Follow my answer on stackoverflow http://stackoverflow.com/a/39593871/1831494 and enjoy. – Android Help Sep 20 '16 at 12:19
-
Follow my answer on below question http://stackoverflow.com/questions/39593324/cannot-resolve-symbol-showsoftinput/39593871#39593871 – Android Help Sep 20 '16 at 12:20
2 Answers
0
Is there a particular EditText you want to have focus first for the numeric keyboard?
If so then try this on the relevant EditText:
XML:
<EditText
android:id="@+id/myEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number">
<requestFocus/>
</EditText>
OR Runtime (onCreate):
EditText editText = new EditText(this);
editText.requestFocus();
editText.setInputType(InputType.TYPE_CLASS_NUMBER);

Mark
- 9,604
- 5
- 36
- 64
-
-
I have shown you above? Use one or the other, obviously not both. I have edited the xml version it to show as typical complete example. Also in your java file just addEditText editText = (EditText) findViewById(R.id.myEditText); hope this helps! – Mark Apr 02 '15 at 10:21
-