简体   繁体   English

从TabActivity调用startActivityForResult

[英]Call startActivityForResult From the TabActivity

I am having a TabActivity class which is hosting three tabs Tab1 Tab2 and Tab3 I want to start an activity from tab2 which delivers result to tab1. 我有一个TabActivity类,该类托管三个选项卡Tab1 Tab2和Tab3,我想从tab2开始一个活动,该活动将结果传递给tab1。 All the tabs are hosted in a class MyTabActivity.java Plz help guyz 所有选项卡都托管在类MyTabActivity.java中。

Activity assigned to tabs cannot be replaced with another activity. 分配给选项卡的活动不能用其他活动替换。 Instead try changing its contents. 而是尝试更改其内容。

You can use public abstract MenuItem add (int groupId, int itemId, int order, int titleRes) method for this TabActivity like,.. 您可以为此TabActivity使用public abstract MenuItem add (int groupId, int itemId, int order, int titleRes)方法。

menu.add(1, 1, 1, "TAB1");

and you can refer this link for the next steps,.. 您可以参考此链接进行下一步。

http://developer.android.com/reference/android/view/Menu.html#add%28int,%20int,%20int,%20int%29 http://developer.android.com/reference/android/view/Menu.html#add%28int,%20int,%20int,%20int%29

Got a solution for the issue. 找到了解决该问题的方法。 It is difficult to start an intent for result when a particular tab is pressed as the result can not be recieved. 当按下特定的选项卡时,很难启动结果意图,因为无法接收到结果。 The simple solution for this is to use public static variables to get data from one class to another. 一个简单的解决方案是使用公共静态变量将数据从一个类发送到另一个类。

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

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