2017-03-08 23 views
-1

我在鍵盤上遇到了問題。我做了搜索活動,當我搜索任何內容時,我會調用編輯文本,並通過單擊該搜索鍵盤仍然在另一活動中激活。我怎麼能阻止它。我想太多,但我需要有人幫如何在android studio中的下一個活動中禁用鍵盤

@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) { 

    } 
+0

你有沒有嘗試設置'機器人:在你的清單windowSoftInputMode'參數? –

+0

請分享您的web_activity.java –

回答

0

嘗試在onItemClick以前startActivity

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
0

寫在你的web_activity.class onCreate方法

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

我希望這將在你的情況下工作,謝謝你

0

你可以簡單地添加到您的活動

 <activity android:name=".activities.YourSampleActivity" 
     android:configChanges="orientation|keyboard|keyboardHidden|screenSize" 
     android:windowSoftInputMode="stateAlwaysHidden" 
     /> 
相關問題