本文整理汇总了Java中android.widget.TabHost.setCurrentTabByTag方法的典型用法代码示例。如果您正苦于以下问题:Java TabHost.setCurrentTabByTag方法的具体用法?Java TabHost.setCurrentTabByTag怎么用?Java TabHost.setCurrentTabByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TabHost
的用法示例。
在下文中一共展示了TabHost.setCurrentTabByTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onShowSearch
import android.widget.TabHost; //导入方法依赖的package包/类
public void onShowSearch()
{
// "deselect" all the visible tabs by selecting the hidden (first) one
TabHost tabHost = (TabHost)findViewById(R.id.tabhost);
tabHost.setCurrentTabByTag("HIDDEN");
// show search as selected
showSearchSelected(true);
// hide all the other tabs
hideAllTabs();
// show the search tab
findViewById(R.id.searchTab).setVisibility(View.VISIBLE);
mSearchText.getText().clear();
}
示例2: setupTabs
import android.widget.TabHost; //导入方法依赖的package包/类
protected void setupTabs()
{
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
// get the tab tags.
mTagHidden = getResources().getString(R.string.hidden_tab);
mTagFile = getResources().getString(R.string.file_tab);
mTagAnnotate = getResources().getString(R.string.annotate_tab);
mTagPages = getResources().getString(R.string.pages_tab);
// first tab is and stays hidden.
// when the search tab is selected, we programmatically "select" this hidden tab
// which results in NO tabs appearing selected in this tab host.
setupTab(tabHost, mTagHidden, R.id.hiddenTab, R.layout.tab);
tabHost.getTabWidget().getChildTabViewAt(0).setVisibility(View.GONE);
// these tabs are shown.
setupTab(tabHost, mTagFile, R.id.fileTab, R.layout.tab_left);
setupTab(tabHost, mTagAnnotate, R.id.annotateTab, R.layout.tab);
setupTab(tabHost, mTagPages, R.id.pagesTab, R.layout.tab_right);
// start by showing the edit tab
tabHost.setCurrentTabByTag(mTagFile);
tabHost.setOnTabChangedListener(this);
}
示例3: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity=this;
requestWindowFeature(Window.FEATURE_NO_TITLE);
initialLoad();
final TabHost tabHost = getTabHost();
setupAccountsTab(tabHost);
setupBlotterTab(tabHost);
setupBudgetsTab(tabHost);
setupReportsTab(tabHost);
MyPreferences.StartupScreen screen = MyPreferences.getStartupScreen(this);
tabHost.setCurrentTabByTag(screen.tag);
tabHost.setOnTabChangedListener(this);
}
示例4: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logs);
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
// Add All Logs tab
intent = new Intent().setClass(this, ActivityLogTabs.class);
intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_ALL_LOGS);
spec = tabHost.newTabSpec(TAB_TAG_ALL_LOG).setIndicator(getString(R.string.All),
res.getDrawable(R.drawable.icon_log_all_small)).setContent(intent);
tabHost.addTab(spec);
// Add Event Logs tab
intent = new Intent().setClass(this, ActivityLogTabs.class);
intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_EVENT_LOGS);
spec = tabHost.newTabSpec(TAB_TAG_EVENT_LOG).setIndicator(getString(R.string.Events),
res.getDrawable(R.drawable.icon_event_unknown_small)).setContent(intent);
tabHost.addTab(spec);
// Add Action Logs tab
intent = new Intent().setClass(this, ActivityLogTabs.class);
intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_ACTION_LOGS);
spec = tabHost.newTabSpec(TAB_TAG_ACTION_LOG).setIndicator(getString(R.string.Actions),
res.getDrawable(R.drawable.icon_action_unknown_small)).setContent(intent);
tabHost.addTab(spec);
// Add General Logs tab
intent = new Intent().setClass(this, ActivityLogTabs.class);
intent.putExtra(ActivityLogTabs.KEY_INTENT_LOG_TYPE, ActivityLogTabs.KEY_GENERAL_LOGS);
spec = tabHost.newTabSpec(TAB_TAG_GENERAL_LOG).setIndicator(getString(R.string.General),
res.getDrawable(R.drawable.icon_log_general_small)).setContent(intent);
tabHost.addTab(spec);
String tabTag = getIntent().getStringExtra(KEY_TAB_TAG);
if (tabTag == null) {
tabHost.setCurrentTabByTag(TAB_TAG_ALL_LOG);
} else {
Log.w("LOGS", "tabTag is "+ tabTag);
tabHost.setCurrentTabByTag(tabTag);
}
}
示例5: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY)
: null;
hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false)
: false;
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
handleIntent(getIntent());
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
trackRecordingServiceConnection = new TrackRecordingServiceConnection(
this, bindChangedCallback);
trackDataHub = TrackDataHub.newInstance(this);
tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
viewPager = (ViewPager) findViewById(R.id.pager);
tabsAdapter = new TabsAdapter(this, tabHost, viewPager);
TabSpec mapTabSpec = tabHost.newTabSpec(MyTracksMapFragment.MAP_FRAGMENT_TAG).setIndicator(
getString(R.string.track_detail_map_tab),
getResources().getDrawable(R.drawable.ic_tab_map));
tabsAdapter.addTab(mapTabSpec, MyTracksMapFragment.class, null);
TabSpec chartTabSpec = tabHost.newTabSpec(ChartFragment.CHART_FRAGMENT_TAG).setIndicator(
getString(R.string.track_detail_chart_tab),
getResources().getDrawable(R.drawable.ic_tab_chart));
tabsAdapter.addTab(chartTabSpec, ChartFragment.class, null);
TabSpec statsTabSpec = tabHost.newTabSpec(StatsFragment.STATS_FRAGMENT_TAG).setIndicator(
getString(R.string.track_detail_stats_tab),
getResources().getDrawable(R.drawable.ic_tab_stats));
tabsAdapter.addTab(statsTabSpec, StatsFragment.class, null);
if (savedInstanceState != null) {
tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY));
}
// Set the background after all three tabs are added
ApiAdapterFactory.getApiAdapter().setTabBackground(tabHost.getTabWidget());
trackController = new TrackController(
this, trackRecordingServiceConnection, false, recordListener, stopListener);
}
示例6: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (BuildConfig.DEBUG) Log.d(TAG, "onCreate()");
mApp = (BoincManagerApplication)getApplication();
// Create handler for screen orientation
mScreenOrientation = new ScreenOrientationHandler(this);
// Obtain screen wake-lock
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getPackageName());
doBindService();
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main_view);
TabHost tabHost = getTabHost();
Resources res = getResources();
// Tab 1 - Projects
tabHost.addTab(tabHost.newTabSpec("tab_projects")
.setIndicator(getString(R.string.projects), res.getDrawable(R.drawable.ic_tab_projects))
.setContent(new Intent(this, ProjectsActivity.class)));
// Tab 2 - Tasks
tabHost.addTab(tabHost.newTabSpec("tab_tasks")
.setIndicator(getString(R.string.tasks), res.getDrawable(R.drawable.ic_tab_tasks))
.setContent(new Intent(this, TasksActivity.class)));
// Tab 3 - Transfers
tabHost.addTab(tabHost.newTabSpec("tab_transfers")
.setIndicator(getString(R.string.transfers), res.getDrawable(R.drawable.ic_tab_transfers))
.setContent(new Intent(this, TransfersActivity.class)));
// Tab 4 - Messages
tabHost.addTab(tabHost.newTabSpec("tab_messages")
.setIndicator(getString(R.string.messages), res.getDrawable(R.drawable.ic_tab_messages))
.setContent(new Intent(this, MessagesActivity.class)));
// Set all tabs one by one, to start all activities now
// It is better to receive early updates of data
tabHost.setCurrentTabByTag("tab_messages");
tabHost.setCurrentTabByTag("tab_tasks");
tabHost.setCurrentTabByTag("tab_transfers");
tabHost.setCurrentTabByTag("tab_projects");
// Set saved tab (the last selected on previous run) as current
SharedPreferences globalPrefs = PreferenceManager.getDefaultSharedPreferences(this);
int lastActiveTab = globalPrefs.getInt(PreferenceName.LAST_ACTIVE_TAB, 1);
tabHost.setCurrentTab(lastActiveTab);
// Restore state on configuration change (if applicable)
final SavedState savedState = (SavedState)getLastNonConfigurationInstance();
if (savedState != null) {
// Yes, we have the saved state, this is activity re-creation after configuration change
savedState.restoreState(this);
}
else {
// Just normal start
ClientId clientId = getIntent().getParcelableExtra(ClientId.TAG);
if (clientId == null) {
String autoConnectHost = globalPrefs.getString(PreferenceName.AUTO_CONNECT_HOST, null);
if ((autoConnectHost != null) && globalPrefs.getBoolean(PreferenceName.AUTO_CONNECT, false)) {
// We should auto-connect to recently connected host
HostListDbAdapter dbHelper = new HostListDbAdapter(this);
dbHelper.open();
mSelectedClient = dbHelper.fetchHost(autoConnectHost);
if (BuildConfig.DEBUG) Log.d(TAG, "Will auto-connect to " + mSelectedClient.getAddress() + ":" + mSelectedClient.getPort());
dbHelper.close();
}
}
}
}