活动之间切换黑屏
我正在使用我的一个活动中的以下代码来启动另一个活动
Intent viewIntent = new Intent(getApplicationContext (), landingPage.class);
Bundle b = new Bundle();
b.putString("ApplicationName", a_Bean.getApplicationName());
if (landingPage.getInstanceCount() < 1)
bp.landingPage_ProgressDialog = ProgressDialog.show(ViewAllApp.this, "Please wait...", "Retrieving data...", true, false);
viewIntent.putExtras(b);
viewIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(viewIntent,10);
Thread background = new Thread(new Runnable() {
public void run() {
Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog
}});
background.start();
,但在启动活动后它显示黑屏&然后显示新活动。 我可以让进度对话框在显示黑屏时显示吗?
I am using below code from one of my activity to start another
Intent viewIntent = new Intent(getApplicationContext (), landingPage.class);
Bundle b = new Bundle();
b.putString("ApplicationName", a_Bean.getApplicationName());
if (landingPage.getInstanceCount() < 1)
bp.landingPage_ProgressDialog = ProgressDialog.show(ViewAllApp.this, "Please wait...", "Retrieving data...", true, false);
viewIntent.putExtras(b);
viewIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(viewIntent,10);
Thread background = new Thread(new Runnable() {
public void run() {
Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog
}});
background.start();
but after startactivity it shows a black screen & then displays new activity.
Can I make progressdialog to be shown while the black screen is displayed??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这对我有用:
This worked for me:
你的代码有点混乱和不清楚。请具体说明目标。无论如何,我看到了一些事情:
1-不要使用 getApplicationContext(),活动本身就是一个上下文,因此最好使用:
2-您不需要创建一个 Bundle 来将字符串添加到意图中。
不管怎样,在你的活动中传递应用程序的名称对我来说似乎是一个可怕的主意。如果您确实需要在整个活动中使用应用程序的名称,请创建一个应用程序类作为应用程序的中心点。我真的建议你重新审视你的架构。
3- 您确定要从其父活动landingPage 访问活动吗?我假设landingPage 是在某处实例化的。我发现这是一个糟糕的方法。如果我错了,请提供例子。
至于代码的其余部分和你的确切问题,我无法回答它,我没有使用过进度对话框,但我们甚至不知道“bp”变量是什么,正如我所说,你应该尝试再次提出您的问题,以澄清一些要点。
Your code is a bit confusing and unclear. Please specify the goal. Anyway, some things I see:
1- Do not use getApplicationContext(), an Activity is a Context itself, thus it's better to use:
2- You don't need to create a Bundle to add a string to to an intent.
Anyway, passing around your activities the application's name seems like a horrible idea to me. If you really need the application's name throughout the activities, create an Application class as the central point of your application. I really recommend you to revisit your architecture.
3- Are you sure you want to access the activity landingPage from its father? I assume that landingPage is instantiated somewhere. I find this to be a terrible approach. If I am wrong, please provide examples.
As for the rest of the code and your precise question, I can't answer it, I haven't worked with Progress dialogs, but we don't even know what the "bp" variable is and, as I said, you should try to ask again your question clarifying some points.
我通过从被调用类(即我的landingPage.class)中删除DataLoader(即从Internet加载数据的方法)到调用者类来解决上述问题。
I resolved above issue by removing DataLoader(i.e. methods that load data from Internet) from called class(i.e. my landingPage.class) to the caller class.