弹出对话框

来源:互联网 发布:linux ftp 目录权限 编辑:程序博客网 时间:2024/05/16 05:31

 

先定义

private View view;private AlertDialog mProtocolDialog;


 

弹出对话框

 

private void loadProtocol() {LayoutInflater webLayout = LayoutInflater.from(this);view = webLayout.inflate(R.layout.protocol_dialog, null);view.setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View arg0, MotionEvent arg1) {StringBuilder sb = new StringBuilder();sb.append(getString(R.string.protocol));TextView protocolContent = (TextView) view.findViewById(R.id.protocol_content);protocolContent.setText(sb.toString());view.setOnTouchListener(null);return false;}});mProtocolDialog = new AlertDialog.Builder(this).setTitle(getString(R.string.protocol_title)).setView(view).setPositiveButton(getString(R.string.agree), new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface arg0, int arg1) {}}).setNegativeButton(getString(R.string.disagree),new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface arg0, int arg1) {}}).show();mProtocolDialog.setOnKeyListener(new OnKeyListener() {@Overridepublic boolean onKey(DialogInterface arg0, int keyCode, KeyEvent arg2) {if (keyCode == KeyEvent.KEYCODE_SEARCH) {}return false;}});}

原创粉丝点击