gpt4 book ai didi

android - 键盘未显示在带有 EditText ListView 的警报对话框中

转载 作者:行者123 更新时间:2023-12-05 08:27:13 25 4
gpt4 key购买 nike

//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 Manifest 中使用了 adjustPan。我在一个对话框中使用了一个 EditTexts 列表,这将使我编写代码的方式变得不可能。此外,它很长,不会让键盘显示以适合屏幕。

这是场景的屏幕截图: dialog

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

最佳答案

感谢 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);
}
});

关于android - 键盘未显示在带有 EditText ListView 的警报对话框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43839419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com