【发布时间】:2018-12-04 00:10:39
【问题描述】:
我有一个自定义对话框,显示方式如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dict_add_word_dialog_box);
ok = findViewById(R.id.dictDialog_confirmButton);
cancel = (Button) findViewById(R.id.dictDialog_cancelButton);
ok.setOnClickListener(this);
cancel.setOnClickListener(this);
}
点击浮动操作按钮时显示,通过:
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DictCustomDialogBoxClass customDialog = new DictCustomDialogBoxClass(DictionaryActivity.this);
customDialog.show();
refreshRecyclerView();
}
});
我想要 refreshRecyclerView();仅在用户按下对话框上的 OK 按钮后运行。我该怎么做呢?
另外,只有当用户按下“确定”而不是“取消”时,我将如何运行它?
【问题讨论】:
-
你会在这里找到答案,stackoverflow.com/a/15020949/3460038
-
Dialogs 有一些事件监听器。看到这个:https://stackoverflow.com/questions/21438100/how-to-handle-alertdialog-close-event?rq=1