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 374 times
2
-
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
5 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
- 2,135
- 3
- 28
- 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,361
- 1
- 16
- 31
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,055
- 8
- 16
0
<activity android:name=".YourActivity" android:windowSoftInputMode="stateHidden" />
Add this to your manifest file...Try this...
Looking Forward
- 4,200
- 8
- 46
- 66
-
will the on-screen keyboard show itself afterwards if i touch on the EditText? – Shanzid SHaiham Jul 30 '13 at 12:13
-
yes, after adding this to your manifest, keyboard will be shown on the screen if you touch Edittext – Looking Forward Jul 30 '13 at 12:14
-
Lets make a deal..I'll mark your answer correct if you upvote me @Anil Bhatiya – Shanzid SHaiham Jul 30 '13 at 12:19
-
We are not here to deal...important thing is to solve your problem. – Looking Forward Jul 30 '13 at 12:20
-
-
-
Ya....i did..sadly didnt work on my device(Galaxy y Dous Android2.3.6) – Shanzid SHaiham Jul 30 '13 at 17:06
-
-
-
-
-
-
0
put a <requestFocus /> in your xml.
Example :
<Button ...>
<requestFocus />
</Button>
It should be on something other than your EditText
Marc-André Therrien
- 489
- 5
- 19