作者:odile微笑头 | 来源:互联网 | 2023-02-04 15:46
//code of AlertDialog
final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle(R.string.modification);
persoFomulair=new ListView(getActivity());
List>>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 Manifest 中使用了adjustPan.我在对话框中使用了一个EditTexts列表,这使得我无法按照编写代码的方式工作.此外,它很长,不会让键盘显示适合屏幕.
以下是场景:对话框的屏幕截图
请注意,在代码中我只想启用所选的EditText而不启用其他的EditText.
1> Farido mastr..:
我找到了一个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);
}
});