简体   繁体   English

Android - Dialog onResume?

[英]Android - Dialog onResume?

I have an action that takes place in Dialog . 我有一个在Dialog发生的动作。 That action starts another app which results I get in onActivityResult in the Activity . 该操作启动了另一个应用程序,结果我进入了Activity中的onActivityResult Now, I want special "something" to happen when the results are received, but in the Dialog . 现在,我希望在收到结果时发生特殊的“某事”,但是在Dialog Is there something like onResume or onActivityResult but for dialogs? 有没有类似onResumeonActivityResult但对于对话框?

Yes. 是。 You can create an Activity and give it a Dialog theme. 您可以创建一个Activity并为其指定一个Dialog主题。 It'll work just like an Activity, but look like a dialog. 它就像一个Activity一样工作,但看起来像一个对话框。

Just add this 只需添加这个

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

If you don't want to go this route you can also use Message Handlers. 如果您不想使用此路由,也可以使用消息处理程序。 That way you can pump message to where ever from where ever. 这样你就可以将信息传递到任何地方。

This is a decent post. 这是一个体面的职位。 http://idlesun.wordpress.com/2010/12/12/android-handler-and-message-tutorial/ http://idlesun.wordpress.com/2010/12/12/android-handler-and-message-tutorial/

You could wrap your Dialog in an Activity , create a variable to house your Dialog , then in onCreate() for the Activity , build the actual Dialog and show() it. 您可以将Dialog包装在Activity ,创建一个变量来存放Dialog ,然后在onCreate()中包含Activity ,构建实际的Dialogshow()它。 When the Activity receives the results, it could reference the Dialog by the variable name and call any necessary methods. Activity收到结果时,它可以通过变量名引用Dialog并调用任何必要的方法。

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

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