启动活动显示黑色闪光闪光、黑色

由网友(月满一江水)分享简介:当我试图从第一个启动第二个活动,但它表明我出新的活动布局之前黑屏。这是我的code:When I am trying to start second activity from the first one, but it shows me black screen before showing new activit...

当我试图从第一个启动第二个活动,但它表明我出新的活动布局之前黑屏。这是我的code:

When I am trying to start second activity from the first one, but it shows me black screen before showing new activity layout. Here is my code:

Intent intent = new Intent(MessagesActivity.this, MessageTextActivity.class);
intent.putExtra("Sender", items.get(position).subject);
intent.putExtra("Date", items.get(position).date);
intent.putExtra("Text", items.get(position).text);
intent.putExtra("Position", position);
startActivity(intent);

在Android上的不是奇巧:当我在清单下添加应用程序 Android其它:主题=@安卓风格/ Theme.Translucent.NoTitleBar,我不开始其他活动时,看到黑色的轰动。这是伟大的,但如果我删除机器人:主题黑色闪又回来了

On Android other than KitKat when I add in manifest under application android:theme="@android:style/Theme.Translucent.NoTitleBar", I don't see black splash when starting other activity. Which is great, but if I remove android:theme the black splash is back.

在另一方面,的奇巧,当我删除 安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar从清单中,它的工作好。 但是,如果我把安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar我也打开其他活动时,没有看到黑色的闪屏,但我还有其他的问题。现在的问题是,如果用户点击了查看这将启动新的活动很多倍,比如果在桌面上的那个地方有些图标,该应用程序被启动!看来,我的活动(一个在我点击查看来打开其他)消失,用户点击桌面上的(主屏幕)图标。

In the other hand, on KitKat, when I remove android:theme="@android:style/Theme.Translucent.NoTitleBar" from manifest, it works good. But, if I keep android:theme="@android:style/Theme.Translucent.NoTitleBar" I also don't see black splash screen when opening other activity, but I have other problem. The problem is if user clicks that View which starts new activity a lot of times, than if there is some icon on desktop in that place, that application gets started! It seems that my activity(the one where I click View to open other) disappeared, and user clicked on icon on desktop (home screen).

安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar在清单帮助我的Andr​​oid除了在奇巧的所有版本。

Putting android:theme="@android:style/Theme.Translucent.NoTitleBar" in manifest helps me in all versions of Android except in KitKat.

编辑:15/8/2014

查看我点击是的ListView 项。当我点击查看第一次我没有看到黑屏闪烁。但是,如果我离开我刚刚进入活动(点击后退),如果我等待1-2秒钟,我点击查看我没有看到黑色闪光再次。但是,如果我以前1-2秒单击,然后出现黑屏闪烁。

This View I am clicking on is a ListView item. When I click on View the first time I don't see black screen flash. But if I exit the activity I just entered(click on Back), and if I wait for 1-2 seconds and I click on the View I don't see black flash again. But If I click before 1-2 seconds, then the black screen flash appears.

在第一个活动,在 onResume 的方法,我没有什么。而在第二个活动,在的onCreate 的方法,我有这个code:

In the first activity, in onResume method, I don't have anything. And in second activity, in onCreate method, I have this code:

ThemeManager.loadTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_message);
initTextViews();
initActionBar();

ThemeManager.loadTheme(本)我在活动设置的样式(因为用户可以更改主题的应用程序),以及风格的定义是这样的: <样式名称=Theme.MyTheme.Blue父=@风格/ Theme.Sherlock.Light> <样式名称=Theme.MyTheme.Green父=@风格/ Theme.Sherlock.Light>

In ThemeManager.loadTheme(this) I set the style in my activity (because user can change themes in the app), and that styles are defined like this: <style name="Theme.MyTheme.Blue" parent="@style/Theme.Sherlock.Light"> and <style name="Theme.MyTheme.Green" parent="@style/Theme.Sherlock.Light">

我使用夏洛克风格

解决方案:)

我发现是什么原因导致这种黑屏。我闭合第二活动时,并示出第一个被添加的动画。动画的进入时间长于退出活动的持续时间。在进入动画仍在进行中,然后我点击查看这将打开新的活动,与黑色的屏幕闪!无论如何,对建议非常感谢。

I found what was causing this black screen. I added animation when closing the second activity, and showing the first one. The entering duration of animation was longer than duration of exiting activity. The entering animation was still in progress, and then I click View which opens new activity with black screen flash! Anyway, many thanks on suggestions.

推荐答案

我遇到了类似的问题,并通过增加主题的第二活动的Andr​​oidManifest.xml 解决:

I faced a similar problem, and solved by adding theme to second activity in AndroidManifest.xml:

<activity android:name="com.example.SecondActivity"
    android:theme="@style/AppTheme.Transparent"/>
阅读全文

相关推荐

最新文章