I have a problem. In the first Activity of my app I have an EditText at the very top of the page inside a linear layout. Problem is that when i run my app, always the EditText is selected for which a keyboard appears on the screen. Is there any way to tell the app not to have the EditText already selected when the app runs? Thanks in advance, Waiting for your reply...
Asked
Active
Viewed 393 times
3
-
measn keyboard automatically open whenever you run the application? – Shani Goriwal Jul 30 '13 at 12:09
-
ya...whenever i run the app – Shanzid SHaiham Jul 30 '13 at 12:14
-
Read this thread, it's very well explained: http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup – CAPS LOCK Jul 30 '13 at 12:15
4 Answers
2
use this code..whenever your project is on, edit-text selected. you will type instantly..
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:ems="10" >
</EditText>

harikrishnan
- 1,985
- 4
- 32
- 63
2
You can make a method and call it on onCreate() method:
public static void hideSoftKeyboard (Activity activity, View view) {
InputMethodManager imm =(InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);}
or simply you can add in manifest file like this:
<activity android:name="com.your.package.ActivityName"
android:windowSoftInputMode="stateHidden" />

Shani Goriwal
- 2,111
- 1
- 18
- 30
1
Remove <requestfocus />
from your <EditText />
in XML file.. Request focus means it is gain focus on particulat component.. So remove it...

Savan Kachhiya Patel
- 1,074
- 8
- 16
0
put a <requestFocus />
in your xml.
Example :
<Button ...>
<requestFocus />
</Button>
It should be on something other than your EditText

Marc-André Therrien
- 519
- 5
- 21