4 つのタブウィジェットがあり、最初の 3 つをクリックすると、それぞれのアクティビティを開始する必要があります。4 つ目のタブをクリックすると、レイアウトはバックグラウンドで以前のアクティビティになり、タブのすぐ下にクイックアクション タイプのダイアログ ボックスが表示されます。これは可能ですか?誰か提案をください。
1 に答える
0
それが役立つことを願っています!クラス TabhostActivity (TabActivity を拡張) で、以下を追加する必要があります。
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, your_first_tab.class);
// Initialize a TabSpec for the first tab
spec = tabHost.newTabSpec("").setIndicator("",res.getDrawable(R.drawable.ic_tab_name_of_the_first_tab)).setContent(intent);
tabHost.addTab(spec);
// Initialize a TabSpec for the second tab
intent = new Intent().setClass(this, your_second_tab.class);
spec = tabHost.newTabSpec("").setIndicator("",res.getDrawable(R.drawable.ic_tab_name_of_the_second_tab)).setContent(intent);
tabHost.addTab(spec);
他の人も同じ仕事。
ic_tab_name_of_the_first_tab は、次のような xml ファイルです。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/first_icon_grey"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/first_icon_white" />
于 2012-06-12T11:30:05.657 に答える