如何完成激活对话的活动?
添加了对话框
AddSyncContactDialog dialog = new AddSyncContactDialog();
Bundle d = new Bundle();
d.putString("number", nums.get(nums.size() - 1));
dialog.setArguments(d);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.addToBackStack(null);
dialog.show(ft, nums.get(nums.size() - 1));
在活动onBackPressed
@Override public void onBackPressed() {
finish();
}
但它仍然关闭对话,但不关闭活动
答案 0 :(得分:0)
使用像
这样的对话框的keylistenerdialog.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog1, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
}
return true;
}
});
并设置dialog.setCancelable(true);