2

是否可以创建一个DialogTabs 的?

如果可能,通过选择其中一个Tab我必须调用 an Activity,是否可以通过 a 传递值Bundle

4

1 回答 1

1

为此,您可以使用 android 的 tabHost 类。 http://developer.android.com/reference/android/widget/TabHost.html

在列表中的 onItemClick 中,检索客户名称并将其放入意图中,然后像这样调用扩展 tabActivity 的类,

Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
Bundle b = new Bundle();
b.putString("name", name);
intent.putExtras(b);
startActivity(intent);
finish();

在选项卡活动中从包中删除数据

Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost
    TabHost.TabSpec spec; // Resusable TabSpec for each tab
    Intent intent; // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, firsttabActivity.class);
    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("first").setIndicator("first", res.getDrawable(R.drawable.ic_tab_shuffle)).setContent(intent);
    tabHost.addTab(spec);

    // Do the same for the other tabs
    intent = new Intent().setClass(this, secondtabActivity.class);
    spec = tabHost.newTabSpec("second").setIndicator("second", res.getDrawable(R.drawable.ic_tab_shuffle)).setContent(intent);
    tabHost.addTab(spec);

现在您可以将客户名称与选项卡中的意图一起传递,并使活动提取它并使用您自己的逻辑使用客户名称来检索客户详细信息。我不知道是否有任何更有效的方法来做到这一点。这只是我首先想到的。我希望它有帮助。

于 2012-03-12T17:48:29.357 回答