如何将结果返回到tabhost活动?

时间:2012-12-06 10:54:57

标签: android android-layout android-tabhost

我使用2个活动A和B,其中A是tabhost中的活动。

我从A

调用活动B.

用于调用活动的代码

 mybund.putString("event", obj_rowitem.getevent());
Intent schedule = new Intent(getApplicationContext(), Schedule.class);
schedule.putExtras(mybund);
startActivityForResult(schedule, req_code);

活动B将一些数据返回给活动A

B中的代码

Bundle mybund = new Bundle();
mybund.putString("date",date);
Intent data = new Intent();
data.putExtras(mybund);
setResult(RESULT_OK, data);
Log.e("going",date);
finish();

我在A上使用OnActivity结果。

但是写在onactivityresult块上的代码不起作用

1 个答案:

答案 0 :(得分:0)

如果您的活动A在选项卡主机中,那么您必须将startActivityForResult与tabhost的上下文一起使用。下面是相同的例子

((YourTabGroup) className.this.getParent()).startActivityForResult(intent, code);
相关问题