android AlertDialog 捕获返回键
1、AlertDialog? 捕获返回键的处理,使用setOnKeyListener事件可以。
2、AlertDialog? setView自定义的布局,去除上下左右的距离时使用的是:
builder.setView(shareView, 0, 0, 0, 0),
并且还要用AlertDialog builder = new AlertDialog.Builder(ProductActivity.this).create();
;
?
AlertDialog builder = new AlertDialog.Builder(ProductActivity.this).create();builder.setTitle(R.string.share_here);View shareView = getLayoutInflater().inflate(R.layout.share_view, null);shareView.setPadding(0, 0, 0, 0);builder.setView(shareView, 0, 0, 0, 0);builder.setOnKeyListener(new OnKeyListener() {@Overridepublic boolean onKey(DialogInterface dialog, int keyCode,KeyEvent event) {if (keyCode == KeyEvent.KEYCODE_BACK&& event.getRepeatCount() == 0) {isReturn = false;}return false;}});builder.setButton(getString(R.string.Ensure),new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface arg0, int arg1) {}});builder.show();
??