-2

i had problem in keyboard . i made search activity and there i call edit text when i search for anything and by clicking that search the keyboard still activate in another activity . how can i stop it. i tried too much but i need someone help

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_activity);
    searchText = (EditText) findViewById(R.id.Search_Field);
    searchText.addTextChangedListener(this);
    resultView = (ListView) findViewById(R.id.Display_Result);
    resultView.setOnItemClickListener(this);

@Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        Intent intent = new Intent(SearchActivity.this, web_activity.class);
        intent.putExtra("url", links[position]);
        startActivity(intent);
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }
Atef Hares
  • 4,715
  • 3
  • 29
  • 61

3 Answers3

0

try that in onItemClick before startActivity

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
Atef Hares
  • 4,715
  • 3
  • 29
  • 61
0

write this in your web_activity.class onCreate method

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

i hope this will work in your case thank you

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

You can simply add this to your activity

        <activity android:name=".activities.YourSampleActivity"
        android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
        android:windowSoftInputMode="stateAlwaysHidden"
        />
Adrian Olar
  • 2,883
  • 4
  • 35
  • 63