您的位置:首页 > 移动开发 > Android开发

自定义AlertDialog,以及解决自定义Dialog中EditText不能弹出输入法的问题

2013-12-17 17:06 531 查看
private void showAlertDialog(final int position,String name,int count) {LayoutInflater inflater = LayoutInflater.from(context);View view = inflater.inflate(R.layout.shoppingcart_editcount, null);final AlertDialog dialog = new AlertDialog.Builder(context).create();//先设置一边setview(),可以解决edittext不能弹出输入法的问题dialog.setView(view);dialog.show();Window window = dialog.getWindow();window.setContentView(R.layout.shoppingcart_editcount);TextView textview = (TextView) window.findViewById(R.id.shoppingcart_editcount_productname_textview);final EditText editText = (EditText) window.findViewById(R.id.shoppingcart_editcount_count_edittext);Button positiveButton = (Button) window.findViewById(R.id.positiveButton);Button negativeButton = (Button) window.findViewById(R.id.negativeButton);textview.setText(name);editText.setHint(String.valueOf(count));positiveButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {}});negativeButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {}});}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android