0

I am designing a Tab based Android application and using Fragment. My first fragment Layout have few Edittexts and on navigating to other fragment which don't have any EditTexts, on tap is getting Virtual keypad to appear. And after few hours of testing, I found its caused by the EditText which is in the previous fragment. How to prevent this ?

Joseph
  • 1,060
  • 3
  • 22
  • 53

2 Answers2

0

Use this in ur activity where you dont want a virtual keyboard

activity=this.getActivity();
    InputMethodManager inputMethodManager = (InputMethodManager)  activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftkey(activity.getCurrentFocus().getWindowToken(), 0);
Abx
  • 2,852
  • 4
  • 30
  • 50
  • I tried using getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); in onActivityCreated. But didn't got what i want. Now used Request focus and that too fails. I also made the foreground layout clickable, longClick, focus, focusOnTouchMode false but same happens. And is not an activity, its fragment. But I used the same as you(Abilash) said. Still searching for the solution. – Joseph Mar 21 '13 at 07:01
0

@Joseph, Try to mention the efforts and implementation you have achieved up till now, this helps to point out the error or a mistake. For your question, try to set the focus of the layout you want to interact with. This may help you to have a requestCall()

Also check this:

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Here is how you can set focus in XML. Put this code within the tag of the control you want the focus on when starting the application.

   <requestFocus
            android:duplicateParentState="true"
            android:focusable="true"
            android:focusableInTouchMode="true" />
Jibran Khan
  • 3,236
  • 4
  • 37
  • 50