先定义
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() {
@Override
public 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() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
}).setNegativeButton(getString(R.string.disagree),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
}).show();
mProtocolDialog.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent arg2) {
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
}
return false;
}
});
}