键盘警告对话框中并没有显示的EditText

问题描述:

的ListView的

键盘警告对话框中并没有显示的EditText

//code of AlertDialog 
 
     final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); 
 
     alert.setTitle(R.string.modification); 
 
     persoFomulair=new ListView(getActivity()); 
 
     List<HashMap<Boolean,HashMap<String,String>>>list = prepareList(p); 
 
     MyListAdapter2 myListAdapter2 = new MyListAdapter2(getActivity(), R.layout.perso_list, list); 
 
     persoFomulair.setAdapter(myListAdapter2); 
 
     alert.setView(persoFomulair); 
 

 
     alert.setPositiveButton(R.string.valider, new DialogInterface.OnClickListener() { 
 
      public void onClick(DialogInterface dialog, int whichButton) { 
 
       //What ever you want to do with the value 
 

 

 
       getValueOfItem(); 
 
       ModifierPerso modifierPerso = new ModifierPerso(); 
 
       modifierPerso.execute(type, String.valueOf(p.getId()), date_embauch, salair_journ); 
 
      } 
 

 
     }); 
 
     alert.setNegativeButton(R.string.annuler, new DialogInterface.OnClickListener() { 
 
      public void onClick(DialogInterface dialog, int whichButton) { 
 
       // what ever you want to do with No option. 
 

 
      } 
 
     }); 
 
     AlertDialog alertDialog=alert.create(); 
 
     alertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); 
 

 
     alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); 
 
     alertDialog.show(); 
 
     
 
     //what i think you need to see is the only parts from the array adapter bellow this comment 
 
        if(type.equals("Date embauch :")){editText.setText(result);editText.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE);} 
 
      else if(type.equals("Salair Journal :")){editText.setText(result);editText.setInputType(InputType.TYPE_CLASS_NUMBER);} 
 
      else {editText.setVisibility(View.GONE);textView.setText(type+result);} 
 
     

在寻找我的问题,我发现,这是因为在Android清单使用adjustPan的。我在对话框中使用了一个EditTexts列表,这将使我无法编写代码来工作。此外,它很长,不会让键盘显示适合屏幕。

这里的场景的截图: dialog

请注意,在代码中,我只是想让启用所选的EditText,而不是其他人的。

我发现了一个sollution感谢*的问题和答案 这是通过将该到ListView(如果ListView控件在对话框中)

//persoFomulair is a listView with editTexts 
 
persoFomulair.post(new Runnable() { 
 

 
      @Override 
 
      public void run() { 
 
       dialog.getWindow().clearFlags(
 
         WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | 
 
           WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); 
 
      } 
 
     });

试试这个设置已经创建对话框后,

Dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); 

Dialog.getWindow().setSoftInputMode(WindowManager.LayoutPara‌​ms.SOFT_INPUT_STATE_‌​VISIBLE); 
+0

不工作,我认为这个问题是因为使用在广告EditTexts的列表视图IM ialog对不对? –

+0

请发布您的显示对话框和ListView的代码。另外,尝试在dialog.show()之后设置我提到的设置。 –