2013-02-06 81 views
0

我正在创建一个Android小部件。我的窗口小部件有一个View,点击后会打开一个Activity,看起来像Dialog活动对话框为

我已更新AndroidManifest.xml,以便像对话框一样调整此活动。

<activity 
    android:name=".Widget.Widget_OeffneDialog" 
    android:theme="@android:style/Theme.Dialog"> 
</activity> 

这太棒了。

现在我从这个小工具打开应用程序,然后单击主页按钮(应用程序现在在后台),然后单击对话框显示的wdget - 但应用程序的其余部分显示在对话框后面。

喜欢这里: enter image description here

我不希望看到下面的对话框活动上一个活动 - 我该怎么做呢?

回答

5

当您启动从发射的Widget_OeffneDialog活动,Android是简单地恢复当前在后台实例 - 以及任何返回堆栈和历史它包含的内容。

尝试强制您的小部件改为启动活动的新实例。

Intent intent = new Intent(this, A.class); 
intent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
+0

谢谢。这项工作完美无瑕! – StefMa

0

使用Theme.Translucent。半透明主题不会使背景中的应用/视图变暗。 请注意,半透明主题不使用动画,因此您可能需要更改该动画。下面是从Android源主题XML:

<style name="Theme.Translucent"> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:colorBackgroundCacheHint">@null</item> 
    <item name="android:windowIsTranslucent">true</item> 
    <!-- Note that we use the base animation style here (that is no 
     animations) because we really have no idea how this kind of 
     activity will be used. --> 
    <item name="android:windowAnimationStyle">@android:style/Animation</item> 
</style> 
+0

抱歉,但我认为这不是我想要的。该解决方案使背景透明。但是,如果点击后退按钮,应用程序将显示“主” - 活动。我唯一想要的就是像这样的对话框:http://x.co/tMom – StefMa