如何展示活动组中的警报?警报、组中

2023-09-12 10:24:23 作者:谁成就了我的卑微゜

我已经在我的应用程序标签栏,并保持它,我已经使用活动组。在点击这些标签我必须表现出一系列的活动。我的问题是,我不能够显示一个警告对话框,或这些活动中的任何其它对话框。发生错误说无法添加窗口。谁能告诉怎么解决这个问题呢?

I have a tab bar inside my app and to maintain it I have used activity group. On clicking these tabs I have to show a set of activities. My problem is I am not able to show an alert dialog or any other dialogs inside these activities. An error occurs saying "unable to add window". Can anyone tell how to solve this issue?

推荐答案

它给上述错误的语境,因为我提供给alertdialog建设者。

It gives above error because of the Context I was providing to alertdialog builder.

给出:

新AlertDialog.Builder(的getParent())setMessage(世界,你好)显示();

new AlertDialog.Builder(getParent()).setMessage("Hello world").show();

我们只需要调用的getParent(),而不是AlertDialog.Builder(本)

We just need to call getParent() instead of AlertDialog.Builder(this)