2012-12-06 25 views
1

我使用2個活動A和B,其中A是在tabhost中的活動。如何將結果返回到tabhost活動?

我調用從用於呼叫活動

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

活動B A

代碼活性乙一些數據返回到活動中B A

代碼

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塊上的代碼不起作用

+0

看到此http://stackoverflow.com/questions/2497205/how-to-return-a-result-startactivityforresult-from-a-tabhost-activity?rq=1 –

回答

0

如果你的活動A是在標籤的主機,那麼你必須使用startActivityForResult與tabhost的情況下。下面是實施例的相同

((YourTabGroup) className.this.getParent()).startActivityForResult(intent, code); 
+0

你會請給我更多的解釋..? tabhost的上下文意味着駐留tabhost的活動的上下文? – Vikky

+0

http://developer.android.com/reference/android/widget/TabHost.html –

相關問題