5

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();
}
midhunhk
  • 5,560
  • 7
  • 52
  • 83
haythem souissi
  • 3,263
  • 7
  • 50
  • 77
  • Take a look at [this][1]. Let's hope it helps. Cheers [1]: http://stackoverflow.com/questions/1845285/how-to-block-virtual-keyboard-while-clicking-on-edittext-in-android/1845307#1845307 – g00dy Feb 21 '13 at 14:44

6 Answers6

4

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.

null pointer
  • 5,874
  • 4
  • 36
  • 66
3

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);

hardartcore
  • 16,886
  • 12
  • 75
  • 101
3

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>
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
Brian White
  • 307
  • 1
  • 2
  • 11
2

you can also try to disable it in Manifest:

 <activity
  android:name=".activity.SampleActivity"
  android:configChanges="keyboardHidden|orientation"
 />
Klawikowski
  • 605
  • 3
  • 11
2

Inside your layout, add this tag inside a view that is not the DatePicker:

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

This should insure that the DatePicker won't get focus and, thus, won't display the keyboard.

Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
2

Add the following line to your activity in manifest.xml

     android:windowSoftInputMode="stateAlwaysHidden"
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90