0

softkeypad is poping up automatically when i press a button...i have tried following code to stop poping up the softkeypad but in vain...following is the code that i have tried :

public void hideKeyboard(View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Airport.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

even in manifest file i have done the following:

android:windowSoftInputMode="stateHidden"

but surprisingly i haven't used any edittext...but also this softkeypad is poping up....can anyone plz answer this....its an emergency...thank u in advanced

Kalyan Vedala
  • 869
  • 2
  • 14
  • 26
  • is there any control where ur making focus? – KOTIOS Jul 03 '14 at 04:23
  • will you please post your button click method.. – pavanmvn Jul 03 '14 at 04:24
  • just remove android:windowSoftInputMode="stateHidden" this line from manifest. – Jitesh Dalsaniya Jul 03 '14 at 04:26
  • public void onClick(View v) { if (v.getId() == R.id.air_pick) { Intent intent = new Intent(v.getContext(), Airport.class); startActivityForResult(intent, 0); ....air_pick is the button....and Airport is another class where i want to call from Main class...This Airport class only contains buttons and nothing at all....this code is from Main.java class....please anyone can solve this...?? thanks everyone who have tried to help me.. – Dark_knight Jul 03 '14 at 04:29
  • Try this in your manifest android:windowSoftInputMode="stateAlwaysHidden" – SathishKumar Jul 03 '14 at 04:38
  • android:windowSoftInputMode="stateAlwaysHidden" ...also didn't work...can anyone plz...its being urgent...i have tried everything – Dark_knight Jul 03 '14 at 04:47
  • InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); – George Thomas Jul 03 '14 at 04:52
  • can you post your code – learner Jul 03 '14 at 07:03

1 Answers1

0

try this its intresting to hide the softkeypad

InputMethodManager inputManager = (InputMethodManager) this
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    //check if no view has focus:
    View v=this.getCurrentFocus();
    if(v==null)
        return;

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
  • have you reach the goal – Rajaji subramanian Jul 03 '14 at 05:09
  • this also didn't work...its being a real problem...is there any other way...?? – Dark_knight Jul 03 '14 at 05:25
  • post your onclick method,i'll help – Rajaji subramanian Jul 03 '14 at 05:35
  • public void onClick(View v) { if (v.getId() == R.id.air_pick) { Intent i = new Intent(Main.this, Airport.class); startActivity(i);........in this code air_pick is the button to be clicked which is in Main.java class...after clicking it focus should be transfered to Airport.class....this Airport.java contains only 4 buttons and nothing else....and when air_pick button is pressed,Airport.java is called and meanwhile softkeypad pops up... – Dark_knight Jul 03 '14 at 05:42
  • InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); try this and let me inform – Rajaji subramanian Jul 03 '14 at 05:55
  • try this link it will help u dude http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard?rq=1 – Rajaji subramanian Jul 03 '14 at 07:42