自定义AlertDialog里的EditText不能弹出软键盘的解决

昨天在做项目的时候发现一个问题,就是在自定义的AlertDialog里面点击EditText的时候软键盘不能弹出,目前已经解决,要先setView(),大家看代码就明白了;

final AlertDialog dialog = new AlertDialog.Builder(this).create();
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout layout = (RelativeLayout)inflater.inflate(R.layout.activity_test_arcgis, null);
dialog.setView(layout);

dialog.show();
Window window = dialog.getWindow();
window.setContentView(R.layout.activity_test_arcgis);
        
EditText edit_des = (EditText)dialog
.findViewById(R.id.item_arcgis_edit_des);

                                                                                                                            

自定义AlertDialog里的EditText不能弹出软键盘的解决_第1张图片  

自定义AlertDialog里的EditText不能弹出软键盘的解决_第2张图片

你可能感兴趣的:(随记,android)