0

タブホストを持つアプリケーションがあり、タブの 1 つが ActivityGroup です。ActivityGroup GroupA の Activity A1 から ActivityGroup GroupB の Activity B2 に移動したいと考えています。GroupBの主な活動はB1ですが、直接B2に行きたいです。

TabHost から ActivityGroup B オブジェクトを実際に受け取る方法がわかりません。

TabHost で setCurrentTab(int index) を使用して GroupB に移動できます。しかし、どうすればアクティビティ B2 にたどり着けるでしょうか?

4

1 に答える 1

1

Probably this is not a direct answer to you problem, but I'd rather suggest you start using fragments instead of ActivityGroups and a lot of Activities. Using fragments in this case has a lot of benefits:

  1. You can implement a TabHost with Fragments in it instead of Activities. There are samples in Android SDK and in ActionbarSherlock lib on how to implement this. You can also add tabs with Fragments to actionbar.
  2. Replacing fragments in tabs can be easily done with FragmentTransaction class. You won't need to store references to ActivityGroups and write spaghetti code to control activities in tabs.
  3. A lot of activities in tabs and ActivityGroups can lead to OutOfMemoryExceptions.
  4. You can easily switch you Activities in tabs to Fragments.
  5. ActivityGroup is deprecated.
于 2012-07-31T10:45:21.167 に答える