当前位置: 代码迷 >> Android >> android AlertDialog 擒获返回键
  详细解决方案

android AlertDialog 擒获返回键

热度:147   发布时间:2016-05-01 15:28:22.0
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() {			@Override			public 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() {					@Override					public void onClick(DialogInterface arg0, int arg1) {					}				});		builder.show();

??

  相关解决方案