Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard appear automatically on Nexus7 version 4.2

I have a dialog containing a time picker. On all my other phones, all is OK I click on the button , the dialog (containing time picker) appear. Than I set the time.

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

Any one know why I am getting this issue on Nexus7.

Edit: The code is given 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();
}
like image 615
haythem souissi Avatar asked Feb 15 '13 13:02

haythem souissi


4 Answers

Make the layout containing the time picker focusable. And request focus to this layout. Then the DatePicker won't get focus and the keyboard will not be displayed.

like image 57
null pointer Avatar answered Nov 17 '22 05:11

null pointer


Have you ever tried to hide your keyboard on button click after your dialog appears? Something like this :

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

like image 34
hardartcore Avatar answered Nov 17 '22 05:11

hardartcore


I ran into this same issue with me calling for the SoftInputMode(Keyboard) on one Activity in my app and it appearing on all the other Activities. So, I finally had to add android:windowSoftInputMode="stateAlwaysHidden" to my manifest file on the activities I did not want the SoftInputMode(Keyboard) to pop up. This got rid of the keyboard popping up. Here is what my manifest Activity looks like:

<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>
like image 41
Brian White Avatar answered Nov 17 '22 07:11

Brian White


you can also try to disable it in Manifest:

 <activity
  android:name=".activity.SampleActivity"
  android:configChanges="keyboardHidden|orientation"
 />
like image 2
Klawikowski Avatar answered Nov 17 '22 07:11

Klawikowski