試試這個:發送一個intent(像往常一樣通過startActivity())將活動帶到包含標籤的前面。發送一個額外的參數,其中包含標籤的活動或標籤的某個標識符,您希望被打開。評估活動中的額外參數,其中包含選項卡,並讓它切換到參數指定的選項卡。
EDIT
到帶有參數開始的標籤活動:
final Intent i = new Intent(this, YourTabActivity.class);
i.putExtra(TAB_TAG, tag); // TAB_ID see comment below, define some tags for the tabs
this.startActivity(i);
要從意圖提取參數:
覆蓋onNewIntent()
在標籤活性和引入一個字段lastIntent
,設置那裏有this.lastIntent = this.getIntent()
。 (否則你將永遠訪問哪些首先啓動該活動的意圖,而不是最近發送的意圖!)
在onResume
過程的最後一個意圖:
final Bundle extras = this.lastIntent.getExtras();
final String tabTag = extras.getString(TAB_TAG); // define the key TAB_TAG as static string
現在使用tabTag
設置當前標籤。
謝謝,請給我代碼,我不明白。再次感謝您 – Maha 2012-04-23 15:01:07
我添加了一些代碼。 – Stefan 2012-04-23 15:23:52
謝謝你,如果你執行我,讓我告訴你我從你的解決方案中得到什麼,我把這個'最終意圖我=新的意圖(這,myTabActivity.class); i.putExtra(TAB_TAG,tag); // TAB_ID見下面的註釋,爲標籤定義一些標籤 this.startActivity(i);'在報警代碼內部onClick,我也把這個代碼放在報警代碼中'public void onResume(){ \t extras = this.MyPage .getExtras(); \t final String tabTag = extras.getString(TAB_TAG); \t } '然後我把這裏面的標籤活動'公共無效onNewIntent(字符串j){this.mypage = this.getIntent();}'我是嗎?因爲它給我一個語法錯誤 – Maha 2012-04-23 16:15:06