开发者

Android how to putExtra to an activity from TabHost activity?

I have a little problem with sending an extra from one activity to another. I have let's say FirstActivity which starts TabActivity, where I have 5 tabs. When I send putExtra(), from FirstActivity to TabActivity, there is no problem, but I need to send that extra to the Activity, which holds first tab of TabHost. I'm using this code :

TabActivity.class :

int collId = getIntent().getIntExtra("collection_id", 0);
Log.i("Collection ID","Collection ID from SingleCollection.class : "+collId);

intent = new Intent(this, Collection.class);
intent.putExtra("collection_id", collId);

spec = tabHost.newTabSpec("collection").setIndicator("Collection",
                  res.getDrawable(R.drawable.ic_tab_collection))
              .setContent(intent);
tabHost.addTab(spec);

but it's not really working. I'm not receiving the 开发者_StackOverflow社区extra on Collection.class.

So my question is how can I send extra to a content of a tab in TabHost. Hope you understand me...


From the child activity you can call getParent().getIntent() to obtain TabActivity's intent, so you don't need to put extra in the way you are doing this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜