机器人如何putExtra从TabHost活动活动?机器人、putExtra、TabHost

2023-09-12 05:36:44 作者:如梦

我有一个小问题,发送一个额外的从一个活动到另一个。我已经让我们说 FirstActivity 这将启动 TabActivity ,在那里我有5个选项卡。当我把 putExtra(),从 FirstActivity TabActivity ,是没有问题的,但我需要发送额外的活动,其中包含 TabHost 的第一个标签。我使用这个code:

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:

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);

但它不是真正的工作。我没有收到额外的 Col​​lection.class

所以我的问题是我怎么能发送额外的一个标签的 TabHost 内容。希望你能理解我......

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

推荐答案

从您可以致电的getParent()的子活动。getIntent()获得 TabActivity 的意图,所以你不需要投入额外的你正在做这样的方式。

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.