我使用下面的代碼在我的Activity中創建了兩個選項卡。這工作得很好。當我點擊第一個標籤時,我看到了它的內容,另一個點擊了它的內容。如何在Android中獲取標籤點擊?
我想如何根據選中的選項卡將變量值設置爲true或false。但我不知道如何獲得標籤點擊這個標籤。你能幫我解決這個問題嗎?
該代碼:
tabHost.setup();
TabSpec ts = tabHost.newTabSpec("Tab1");
ts.setIndicator("", getResources().getDrawable(R.drawable.tab1_content));
ts.setContent(R.id.tab1Layout);
tabHost.addTab(ts);
TabSpec ts1 = tabHost.newTabSpec("Tab2");
ts1.setIndicator("", getResources().getDrawable(R.drawable.tab2_content));
ts1.setContent(R.id.tab2Layout);
tabHost.addTab(ts1);
我只是通過這個工作我自己。 –