的Android定制Listviewadapterdialog隐藏softinputkeyboard

问题描述:

我对着方案如下的Android定制Listviewadapterdialog隐藏softinputkeyboard

在焦点上我对话的EditText的给我想要的键盘出现在 对话框上方。

enter image description here

我经历了这么多的答案进去SO。但不工作的适配器类的EditText

代码的onfocus

edittext.setOnFocusChangeListener(new OnFocusChangeListener() { 

    public void onFocusChange (View v,boolean hasFocus){ 
     edittext.post(new Runnable() { 

      public void run() { 
       InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
       imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 
      } 
     }); 

列表视图

LayoutInflater li = LayoutInflater.from(context); 
      View promptsView = li.inflate(R.layout.custom_dialog, null); 
      AlertDialog.Builder builder = new AlertDialog.Builder(context); 
      builder.setView(promptsView); 
      builder.setTitle(" Please select size"); 

      listView = (ListView) promptsView.findViewById(R.id.listt); 
      dataAdapter = new MyCustomAdapter(context, R.layout.size_info, 
        sizePojoList, active); 
      listView.setAdapter(dataAdapter); 
      listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); 
      listView.setItemsCanFocus(true); 
+0

你可以发布一些你已经尝试过的代码吗? –

+0

发布一些代码实现或您的布局 –

+0

在打开对话框之前keyvoar是否已经打开? –

尝试:

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 
+0

我累了,这也而不是工作 – Rose

+0

Shmuel

+0

不工作,这也 – Rose