there are two rows one is with textview which is used as datepicker and the second one is edittext, Now my problem is when the activity is open automatically the edittext is keep focusing how to disable the focus from that.
Asked
Active
Viewed 127 times
-1

Cœur
- 37,241
- 25
- 195
- 267

AndroidKing
- 29
- 1
- 2
- 7
-
1Possible duplicate of [Stop EditText from gaining focus at Activity startup](http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup) – Mike M. Sep 12 '16 at 10:41
-
Cant get you..Actually it is my edittext @MikeM – AndroidKing Sep 12 '16 at 10:43
-
I don't understand what your comment means. – Mike M. Sep 12 '16 at 10:47
-
Your question is already answered in many posts. Please [check this post->](http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup) – musica Sep 12 '16 at 10:50
-
Sorry @MikeM. my query is about not to hiding softkey board.. cursor should be blink @ second row in the field of edittext.. – AndroidKing Sep 12 '16 at 10:56
-
No @musica.. I tried with that.. but it couldn't helped:-( – AndroidKing Sep 12 '16 at 10:57
-
I have no idea what you mean, at this point. You'll need to [edit] your question to better explain exactly what it is you want, and how your current setup isn't doing that. Also, please don't make your whole question one big link. – Mike M. Sep 12 '16 at 11:01
3 Answers
0
You can use this code in onCreate() :
public static void hideSoftKeyboard(Activity activity) {
// Check if no view has focus:
try {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
} catch (Exception e) {
//
}
}

RoShan Shan
- 2,924
- 1
- 18
- 38
-
for that i used in ManiFest file _ android:windowSoftInputMode="stateHidden"_ – AndroidKing Sep 12 '16 at 11:00
0
put this line in your manifest under your activity android:windowSoftInputMode="stateUnchanged"

Karthik Thunga
- 1,093
- 2
- 12
- 21
0
add android:windowSoftInputMode="stateHidden|stateAlwaysHidden"
in your activity tag in manifest file

Priya
- 101
- 4