如何通过两款Android视图之间的数据? [英] How pass data between two android views?

查看:146
本文介绍了如何通过两款Android视图之间的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要做下面的一个简单的应用:

I have a simple application that needs to do the following:

  1. 从主视图用户点击一个按钮,启动另一种观点。
  2. 新的视图,并从用户那里收集信息。
  3. 一旦用户点击了新的观点,我需要送的数据返回到原始视图确定。

我发现现在的问题是,一旦我使用StartActivity(含意向)或的setContentView(Resource.Layout.Main)是我的数据已经一去不复返了。我把我收集到一个全局变量中的信息,但是当我回到我的原始查看其再创造。

The problem I am finding is that once I use StartActivity (with an intent) or SetContentView (Resource.Layout.Main) is that my data is gone. I'm putting the information I collected in a global variable but when I get back to my originating view its being recreated.

我怎样才能通过这个数据返回到先前的观点,这样我可以更新一些UI控件?

How can I pass this data back to the originating view so that I can update some UI controls?

推荐答案

HTTP: //developer.android.com/training/basics/intents/result.html

你试过startActivityForResult。我猜那是你在找什么做的。

Have you tried startActivityForResult. I'm guessing that is what you're looking to do.

这篇关于如何通过两款Android视图之间的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆