错误:Theme.Translucent和放大器; FLAG_ACTIVITY_REORDER_TO_FRONT放大器、错误、Translucent、Theme

由网友(づ男人收起你的猥琐)分享简介:我有一个半透明的主题活动:安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar另外的问题是可重复执行与眼前这个主题:<样式名称=MyTheme的父=@安卓风格/主题><项目名称=机器人:windowIsTranslucent>真< /项目><项目名称...

我有一个半透明的主题活动:

 安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar
 

另外的问题是可重复执行与眼前这个主题:

 <样式名称=MyTheme的父=@安卓风格/主题>
    <项目名称=机器人:windowIsTranslucent>真< /项目>
    <项目名称=机器人:windowBackground> @android:彩色/透明< /项目>
    <项目名称=机器人:colorBackground> @空< /项目>
< /风格>
 

该活动在启动时加载和保存在内存(当我开始这个活动,我的广告的 FLAG_ACTIVITY_REORDER_TO_FRONT 标志作为另计)。

问题:当我开始这项活动(从菜单),该活动没有显示出来,没有任何反应。 但是:如果我删除了半透明的主题:一切工作正常,活动后到前

是onNewIntent()被调用。

如果我preSS回半透明活动性低于一个!但它需要的顶部。

出大事了,这家公司竟然在全国免费送酒店自助机

这是例子是

  

A(半透明的活动)B C

     

堆栈:A

     

一个startActivity(B)

     

栈:A,B

     

乙startActivity(C)

     

栈:A,B,C

     

ÇstartActivity(A)//用标志FLAG_ACTIVITY_REORDER_TO_FRONT

     

堆栈的应的:B,C,A

     

但一个永远不会带到前面,但其onNewIntent()被调用。

任何想法?

便笺的

有趣的悬而未决的问题:http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli=1

安卓launchMode的 singleTask singleInstance 不希望被使用。这些改变backstack移动活动纳入自己的堆栈。因此,我们没有A,B,C了。

  

singleTask和singleInstance - 不适合于大多数   应用中,因为它们导致交互模型是可能   为不熟悉的用户,并与大多数其他非常不同   应用程序。

http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

谁想要一个可视化的再$ P $ launchModes的psentation试试这个程序:https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode

解决方案

如果不设置从AndroidManifest.xml中,活动块的主题和主题设置的setContentView之前,在onCreate方法中的第一个半透明的活动,这个问题是解决了,下面是code:

 公共类TranslucentActivityDemoActivity延伸活动{

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
 

  this.setTheme(R.style.myTheme);
 

 的setContentView(R.layout.main);

    }
 

I have an activity with the translucent Theme :

android:theme="@android:style/Theme.Translucent.NoTitleBar"

Also the problem is reproduceable with just this Theme:

<style name="MyTheme" parent="@android:style/Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackground">@null</item>
</style>

This activity is loaded at startup and kept in memory (when I start this activity, I ad the FLAG_ACTIVITY_REORDER_TO_FRONT flag as extra).

Problem : when I start this activity (from the menu), the activity don't show up, nothing happens. But : if I remove the translucent theme : all works fine, the activity is back to front.

Yes onNewIntent() is called.

And if I press back the translucent activity is the one below! But it needs to be the top.

An example being

A ( translucent activity) B C

Stack: A

A startActivity(B)

Stack: A,B

B startActivity(C)

Stack: A,B,C

c startActivity(A) // with flag FLAG_ACTIVITY_REORDER_TO_FRONT

Stack should be: B,C,A

but A is never brought to the front, although its onNewIntent() is called.

Any ideas?

Side notes

Interesting unanswered question: http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli=1

android:launchMode of singleTask or singleInstance are not wanted to be used. These change the backstack and move activities into their own stack. Therefore we don't have A,B,C any more.

singleTask and singleInstance — are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.

http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

Anyone who wants a visual representation of launchModes try this app : https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode

解决方案

If we do not set the theme from AndroidManifest.xml, activity block and set the theme before setContentView, in onCreate method in the first translucent activity, the problem is solved, below is the code:

public class TranslucentActivityDemoActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

      this.setTheme(R.style.myTheme);

        setContentView(R.layout.main);

    }

阅读全文

相关推荐

最新文章