简体   繁体   English

如何与顶部对话框活动下方的活动进行交互?

[英]How to interact with the activity beneath the top dialog activity?

I have a dialog activity staying in the top of a screen but only covering a small portion of it.我有一个对话框活动停留在屏幕顶部,但只覆盖了其中的一小部分。 I know in the normal situation I am not allowed to manipulate the activity under the top one like click some buttons even though I can see it.我知道在正常情况下,即使我可以看到它,我也不允许操作顶部的活动,例如单击某些按钮。 But I really need this ability.但我真的很需要这种能力。 Below is part of my code:以下是我的代码的一部分:

    private void onPlayStreamingClick() {
    Intent intent = new Intent(this.getActivity(), LivePlayerActivity.class);
    intent.putExtra("cache", false);
    intent.putExtra("loop", false);
    startActivity(intent);
}

The theme of LivePlayerActivity is "Theme.Dialog" and it does not cover the full screen. LivePlayerActivity 的主题是“Theme.Dialog”,不覆盖全屏。 So I want to click the buttons in the activity behind LivePlayerActivity which could be seen from the screen.所以我想单击 LivePlayerActivity 后面的活动中的按钮,可以从屏幕上看到。 I know according to the essential mechanism of android lifecycle, after started LivePlayerActivity, the activity contains above code will change to pause status so it is not going to react to any touch or click events from the user.我知道根据android生命周期的基本机制,启动LivePlayerActivity后,包含上述代码的活动将更改为暂停状态,因此它不会对用户的任何触摸或点击事件做出反应。 But I was told there is a way to make this happen and I want to know how.但有人告诉我有一种方法可以做到这一点,我想知道如何做到。 Any help is much appreciated!任何帮助深表感谢!

You can not "modify" the underlying activity behind a dialog directly, or while the dialog is open.您不能直接“修改”对话框背后的底层活动,也不能在对话框打开时“修改”。 You have some options:你有一些选择:

  • Make the changes just before showing the dialog在显示对话框之前进行更改
  • Use dialog callbacks (eg onDialogShowed), or the button ones.使用对话框回调(例如 onDialogShowed)或按钮回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM