2016-07-29 69 views
0

我打開一個一個的EditText活動,當我留在這個活動中,後臺服務啓動一個新的其他行爲的標誌:點擊EditText上不能彈出softkeyboard

intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT 
      | Intent.FLAG_ACTIVITY_NEW_TASK); 

當新的活動被關閉,單擊editText時軟鍵盤無法顯示。

+0

當我按Home按鈕並再次返回時,它會再次工作。 – Bob

+0

您是否在XML文件中添加了編輯文本的輸入類型? –

+0

<的EditText 機器人:ID = 「@ + ID/et_add_contact」 機器人:layout_width = 「match_parent」 機器人:layout_height = 「@捫/ dimen_50」 機器人:layout_margin = 「@捫/ dimen_16」 機器人:layout_below = 「@ + id/title」/>我的xml – Bob

回答

0

你可以試試這個,一旦它適用於我。

final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); 
final EditText input = new EditText(getActivity()); 
alert.setView(input); 
final AlertDialog dialog = alert.show(); 
input.setOnFocusChangeListener(new OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View v, boolean hasFocus) { 
     if(hasFocus) { 
      dialog.getWindow().setSoftInputMode(
       WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE 
      ); 
     } 
    } 
}); 
+0

我不想把EditText放在AlertDialog中。 – Bob