Keyboard automatically appears on Nexus7 version 4.2

I have a dialog containing a timer. On all my other phones, everything is fine. I press the button, a dialog appears (containing the timing). Then I set the time.

In the version of Nexus 7 android 4.2. In landscape mode, when I click on the button, a dialog appears and the keyboard appears automatically. I haven't clicked yet TimePicker.

Does anyone know why I am getting this problem on Nexus7.

Edit: code is below

private DatePicker mDatePicker;

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
   mDatePicker = (DatePicker) view.findViewById(R.id.date_picker);
   mDatePicker.init(mDate.get(Calendar.YEAR), mDate.get(Calendar.MONTH), mDate.get(Calendar.DAY_OF_MONTH), this);
   mDatePicker.clearFocus();
}
+5
source share
6 answers

Make layoutcontaining the timing customizable. And request a focus on this layout. Then DatePickerit will not focus, and the keyboard will not be displayed.

+4

- ? - :

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

+3

, SoftInputMode (Keyboard) Activity , Activities. , , , android:windowSoftInputMode="stateAlwaysHidden" manifest Activities, , SoftInputMode () . . manifest Activity:

<activity
        android:name=".GMax3Main"
        android:label="@string/app_name" 
        android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
            <action android:name="com.medeasy.GMax3.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
+3

:

 <activity
  android:name=".activity.SampleActivity"
  android:configChanges="keyboardHidden|orientation"
 />
+2

DatePicker:

<SomeView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:doSomethingCool="true">
    <requestFocus/>
</SomeView>

, DatePicker , , .

+2

activity manifest.xml

     android:windowSoftInputMode="stateAlwaysHidden"
+2

All Articles