简体   繁体   English

活动的自定义样式-OnStart不起作用

[英]Custom style for activity - OnStart doesn't work

I am kind of newbie here. 我是这里的新手。 But would like to ask you guys for help. 但想请你们帮忙。

so what my app is doing. 所以我的应用程序正在做什么。 In activity#1 I have : 在活动1中,我有:

protected void onStart() where I run void run()

there's a loop that increases int i each second. 有一个循环,每秒会增加int。 Via handler it refreshes textview . 通过处理程序,它刷新textview Until game=false. 直到game = false。 No big deal. 没什么大不了。 Then I have a button that stops loop (by setting game=false ) and starts new activity#2 for result. 然后,我有一个按钮来停止循环(通过设置game=false )并开始新的activity#2以获得结果。 At the moment I have two returning values (0-back, 1-exit) . 目前,我有两个returning values (0-back, 1-exit) When activity#2 returns 0 I set game=true and loop is running again. 当activity#2返回0时,我将game=true设置game=true并且循环再次运行。 In case of 1 I finish activity1. 在1的情况下,我完成活动1。

Issue: I wanted to have trasparent window for activity#2 . 问题:我想要activity#2透明窗口。 So I used android:theme="@style/Theme.Transparent">. 所以我用了android:theme="@style/Theme.Transparent">. Effect works well. 效果很好。 The problem is that when I go back from act2 to act1 it doesn't start loop (it used to work when I didn't use style). 问题是,当我从act2返回到act1时,它不会启动循环(当我不使用样式时,它可以正常工作)。 Can someone explain me why it's happing and how can I solve it? 有人可以向我解释为什么会出现包装问题,我该如何解决?

seems I've solved it. 看来我已经解决了。 Just moved run() stuff into onResume. 刚刚将run()东西移到了onResume中。 what do you think? 你怎么看?

When you do something during when activity is restored, resumed or brought again back to the front override the onResume. 当您在恢复,恢复活动或再次将其重新带回活动期间执行某些操作时,将覆盖onResume。 If you have started the other activity with startActivityForResult(Intent,requesCode), when you go back to the previous activity should override the onActivityResult(int requestCode,resultCode, Intent) of that activity to execute lines of code base on the intent, requestCode or resultCode. 如果您已使用startActivityForResult(Intent,requesCode)启动了另一个活动,那么当您返回上一个活动时,应覆盖该活动的onActivityResult(int requestCode,resultCode,Intent)以基于intent,requestCode或resultCode。

Dig more about android activity here . 在这里详细了解android活动。 :) :)

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

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