2017-05-08 80 views
-1
的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,而不是其他人的。

回答

2

我發現了一個sollution感謝StackOverflow的問題和答案 這是通過將該到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); 
 
      } 
 
     });

0

試試這個設置已經創建對話框後,

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()之後設置我提到的設置。 –