gpt4 book ai didi

Android Custom Listview Adapter Dialog隐藏软输入键盘

转载 作者:太空狗 更新时间:2023-10-29 14:41:53 25 4
gpt4 key购买 nike

下面给出了我面临的场景

On-focus of my dialog edittext I want keyboard to appear above the dialog.

enter image description here

我在 SO 中经历了很多答案。但不工作

code in adapter class 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);
}
});

Listview

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);

最佳答案

尝试:

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

关于Android Custom Listview Adapter Dialog隐藏软输入键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46639283/

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