的Android定制Listviewadapterdialog隐藏softinputkeyboard
问题描述:
我对着方案如下的Android定制Listviewadapterdialog隐藏softinputkeyboard
在焦点上我对话的EditText的给我想要的键盘出现在 对话框上方。
我经历了这么多的答案进去SO。但不工作的适配器类的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);
}
});
列表视图
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);
你可以发布一些你已经尝试过的代码吗? –
发布一些代码实现或您的布局 –
在打开对话框之前keyvoar是否已经打开? –