本文整理汇总了Java中android.widget.TabWidget.getTabCount方法的典型用法代码示例。如果您正苦于以下问题:Java TabWidget.getTabCount方法的具体用法?Java TabWidget.getTabCount怎么用?Java TabWidget.getTabCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TabWidget
的用法示例。
在下文中一共展示了TabWidget.getTabCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTagToLastTab
import android.widget.TabWidget; //导入方法依赖的package包/类
/**
* Last current tab is tagged with the given tabName
* @param tabName
*/
private void addTagToLastTab(String tabName){
TabWidget tabWidget=tabHost.getTabWidget();
int numTabs=tabWidget.getTabCount();
LinearLayout tabIndicator=(LinearLayout)tabWidget.getChildTabViewAt(numTabs - 1);
ImageView imageView = (ImageView)tabIndicator.getChildAt(0);
imageView.setTag(tabName);
}
示例2: addTagToLastTab
import android.widget.TabWidget; //导入方法依赖的package包/类
private void addTagToLastTab(String tabName) {
TabWidget tabWidget = tabHost.getTabWidget();
int numTabs = tabWidget.getTabCount();
ViewGroup tabIndicator = (ViewGroup) tabWidget.getChildTabViewAt(numTabs - 1);
ImageView imageView = (ImageView) tabIndicator.getChildAt(0);
imageView.setTag(tabName);
TextView textView = (TextView) tabIndicator.getChildAt(1);
textView.setGravity(Gravity.CENTER);
textView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
示例3: onCreate
import android.widget.TabWidget; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_view_fragment);
// logo
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setTitle("studieDOKK1");
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.studiedokk1_logo_transparent_white);
}
mTabHost = (FragmentTabHost) findViewById(R.id.tabhost);
mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
public void onTabChanged(String tabId) {
View currentView = mTabHost.getCurrentView();
if (mTabHost.getCurrentTab() > currentTab) {
currentView.setAnimation(inFromRightAnimation());
} else {
currentView.setAnimation(outToRightAnimation());
}
currentTab = mTabHost.getCurrentTab();
}
});
mTabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("tab1").setIndicator("Aktiviteter", null),
ActivitiesGridFragment.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab2").setIndicator("Kort", null),
MapFragment.class, null);
TabWidget tw = mTabHost.getTabWidget();
System.out.println("TW cnt: "+tw.getTabCount());
for(int i = 0; i < tw.getTabCount(); i++){
TextView tv = (TextView) tw.getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(Color.WHITE);
}
mTabHost.setCurrentTab(1);
}
示例4: setUpTabInfos
import android.widget.TabWidget; //导入方法依赖的package包/类
private void setUpTabInfos() {
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
if (tabHost != null) {
tabHost.setup();
final TabWidget tabWidget = tabHost.getTabWidget();
final FrameLayout tabContent = tabHost.getTabContentView();
// Get the original tab textviews and remove them from the viewgroup.
TextView[] originalTextViews = new TextView[tabWidget.getTabCount()];
for (int index = 0; index < tabWidget.getTabCount(); index++) {
originalTextViews[index] = (TextView) tabWidget.getChildTabViewAt(index);
}
tabWidget.removeAllViews();
// Ensure that all tab content childs are not visible at startup.
for (int index = 0; index < tabContent.getChildCount(); index++) {
tabContent.getChildAt(index).setVisibility(View.GONE);
}
// Create the tabspec based on the textview childs in the xml file.
// Or create simple tabspec instances in any other way...
for (int index = 0; index < originalTextViews.length; index++) {
final TextView tabWidgetTextView = originalTextViews[index];
final View tabContentView = tabContent.getChildAt(index);
TabHost.TabSpec tabSpec = tabHost.newTabSpec((String) tabWidgetTextView.getTag());
tabSpec.setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String tag) {
return tabContentView;
}
});
if (tabWidgetTextView.getBackground() == null) {
tabSpec.setIndicator(tabWidgetTextView.getText());
} else {
tabSpec.setIndicator(tabWidgetTextView.getText(), tabWidgetTextView.getBackground());
}
tabHost.addTab(tabSpec);
}
}
}