-3

When i open my Activity my EditText automatically gain focus and it shows keyboard... So how to hide the keyboar..??

Answer :

For Activity place the below code into your onCreate() method

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

For Fragment place the below code into your onCreateView() method

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107

1 Answers1

0

Answer :

For Activity: place the below code into your onCreate() method

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

For Fragment: place the below code into your onCreateView() method

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);