android - 显示对话框将调用哪个 Activity 生命周期函数?

标签 android android-dialog

我使用 - 创建了一个简单的对话框

Dialog dialog = new Dialog(Myactivity.this);
dialog.setContentView(R.layout.myLayout);
dialog.show();

当我显示和关闭此对话框时,我想更新 MyActivity 中的 textView。所以我在 onResume() 中放了一些东西,假设它在您关闭 dialog 时被调用。 是真的吗?或者我们有任何其他方式来更新此 textView 吗?

最佳答案

您可以更新您的 TextView 实现 OnDismissListener interface :

dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
    @Override
    public void onDismiss(DialogInterface dialogInterface) {
            //update your textView
    }
});

关于android - 显示对话框将调用哪个 Activity 生命周期函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25627262/

相关文章:

android - findViewById() 对于对话框中的 View 返回 null

android - Android 中的默认字体特征是什么?

java - Android与json解析

Android - onCreateDialog 在返回 DatePickerDialog 时崩溃

android - 如何制作这个漂亮的Dialog?

android - 在状态栏下方显示 DialogFragment 内容

java - Android定时器抛出空指针异常

android - TaskStackBuilder 过渡动画

android - 如何在 Android 的 EditText 中屏蔽字符?

android - 如何在旋转屏幕后关闭 dialogfragment