Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide softkeyboad when activity start in android?

I have android app in which one layout contains Linearlayout, ScrollView, TextView, EditView and Button. when I call from one activity to other this activity call and set layout which I have describe.

I would like to know when activity call there is by default EditView selected. and open the softkeyboard. I don't want to open that keyboard when activity start. but I want to open that softkeyboard on touch event of EditView.

How can I do that?

like image 771
Urvashi Avatar asked May 13 '11 11:05

Urvashi


People also ask

How do I get rid of soft keyboard on Android?

You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow , passing in the token of the window containing your focused view. This will force the keyboard to be hidden in all situations. In some cases, you will want to pass in InputMethodManager.


2 Answers

In your AndroidManifest.xml:

<activity android:name="com.your.package.ActivityName"           android:windowSoftInputMode="stateHidden"  /> 

More details about windowSoftInputMode can be found here.

This setting will hide soft keyboard when user enters new Activity (even if EditText control gains the focus). Soft keyboard will be shown only when user clicks the edit box control.

like image 177
inazaruk Avatar answered Oct 02 '22 17:10

inazaruk


You can hide keyboard by add two lines to the parent view of editText.

android:focusable="true" android:focusableInTouchMode="true" 
like image 20
mani Avatar answered Oct 02 '22 17:10

mani