AlterDialog在调用show()方法之前是没办法给他的window设置布局的
使用setView() 直接给布局,EditText就能调用键盘了。
虽然原理我还不太了解,推测跟布局的时机有关系。
if (!( channelIdDialog != null && channelIdDialog.isShowing())) { channelIdDialog = builder.create(); channelIdDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); RelativeLayout layout = (RelativeLayout)inflater.inflate(R.layout.dialog_addchannel, null); channelIdDialog.setView(layout); channelIdDialog.show(); } View view = LayoutInflater.from(context).inflate(R.layout.dialog_addchannel, null); channelIdDialog.getWindow().setContentView(view);