当前位置: 首页>>代码示例>>Java>>正文


Java TabWidget类代码示例

本文整理汇总了Java中android.widget.TabWidget的典型用法代码示例。如果您正苦于以下问题:Java TabWidget类的具体用法?Java TabWidget怎么用?Java TabWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TabWidget类属于android.widget包,在下文中一共展示了TabWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPageSelected

import android.widget.TabWidget; //导入依赖的package包/类
@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk.
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = tabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    tabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);

    // Scroll the current tab into visibility if needed.
    View tab = widget.getChildTabViewAt(position);
    tempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom());
    widget.requestRectangleOnScreen(tempRect, false);

    // Make sure the scrollbars are visible for a moment after selection
    final View contentView = tabs.get(position);
    if (contentView instanceof CaffeinatedScrollView) {
        ((CaffeinatedScrollView) contentView).awakenScrollBars();
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:25,代码来源:TabsAdapter.java

示例2: changeTabBackGround

import android.widget.TabWidget; //导入依赖的package包/类
private void changeTabBackGround() { // 改变选项卡的颜色
	// 得到当前选中选项卡的索引
	int index = getTabHost().getCurrentTab();
	// 调用tabhost中的getTabWidget()方法得到TabWidget
	TabWidget tabWidget = getTabHost().getTabWidget();
	// 得到选项卡的数量
	int count = tabWidget.getChildCount();
	// 循环判断,只有点中的索引值改变背景颜色,其他的则恢复未选中的颜色
	for (int i = 0; i < count; i++) {
		View view = tabWidget.getChildAt(i);
		TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(
				android.R.id.title);
		tv.setTextSize(20);
		if (index == i) {
			view.setBackgroundResource(color.holo_blue_dark);
		} else {
			view.setBackgroundResource(color.holo_blue_light);
		}
	}
}
 
开发者ID:z9961,项目名称:DoList,代码行数:21,代码来源:MainActivity.java

示例3: applyTo

import android.widget.TabWidget; //导入依赖的package包/类
public void applyTo(View target) {
    LayoutParams lp = target.getLayoutParams();
    ViewParent parent = target.getParent();
    FrameLayout container = new FrameLayout(this.context);
    if (target instanceof TabWidget) {
        target = ((TabWidget) target).getChildTabViewAt(this.targetTabIndex);
        this.target = target;
        ((ViewGroup) target).addView(container, new LayoutParams(-1, -1));
        setVisibility(8);
        container.addView(this);
        return;
    }
    ViewGroup group = (ViewGroup) parent;
    int index = group.indexOfChild(target);
    group.removeView(target);
    group.addView(container, index, lp);
    container.addView(target);
    setVisibility(8);
    container.addView(this);
    group.invalidate();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:BadgeView.java

示例4: setTabWidget

import android.widget.TabWidget; //导入依赖的package包/类
public void setTabWidget(Context context, TabWidget tabwidget)
{
	SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
	int themeSet = Integer.parseInt(sharedPreferences.getString("preferences_theme_set", "0"));
	int colorThemeSet = Integer.parseInt(sharedPreferences.getString("preferences_color_theme_set", "7"));
	
	for(int i = 0; i < tabwidget.getChildCount(); i++)
	{
		View v = tabwidget.getChildAt(i);

		TextView textview = (TextView)v.findViewById(android.R.id.title);
		if(textview == null)
		{
				continue;
		}

		v.setBackgroundResource(tabwidget_drawable[themeSet][colorThemeSet]);
	}
   }
 
开发者ID:vassela,项目名称:AC2RD,代码行数:20,代码来源:ThemeManager.java

示例5: ensureHierarchy

import android.widget.TabWidget; //导入依赖的package包/类
private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:23,代码来源:FragmentTabHost.java

示例6: handleRequest

import android.widget.TabWidget; //导入依赖的package包/类
@Override
public RPCMessage handleRequest(RPCMessage request, Solo solo, Map varCache) {
    RPCMessage response;
    int hash = Integer.parseInt((String) request.getArgs().get(0));//获取hashcode
    TabWidget tabWidget = (TabWidget) varCache.get(hash);
    if (tabWidget != null) {

        solo.clickOnView(tabWidget.getChildAt(Integer.parseInt((String) request.getArgs().get(1))));
        response = RPCMessage.makeSuccessResult();
    } else {
        response = ErrorResponseHelper.makeViewNotFoundErrorResponse(getClass());
    }

    return response;
}
 
开发者ID:IfengAutomation,项目名称:test_agent_android,代码行数:16,代码来源:SwitchToTab.java

示例7: onPageSelected

import android.widget.TabWidget; //导入依赖的package包/类
@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk.
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);

    // Scroll the current tab into visibility if needed.
    View tab = widget.getChildTabViewAt(position);
    mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom());
    widget.requestRectangleOnScreen(mTempRect, false);

    // Make sure the scrollbars are visible for a moment after selection
    final View contentView = mTabs.get(position);
    if (contentView instanceof CaffeinatedScrollView) {
        ((CaffeinatedScrollView) contentView).awakenScrollBars();
    }
}
 
开发者ID:CmDnoEdition,项目名称:fdroid,代码行数:25,代码来源:TabsAdapter.java

示例8: showTab

import android.widget.TabWidget; //导入依赖的package包/类
public Tab showTab(String name) {
	if (tabHost != null) {
		for (int i = 0; i < tabs.size(); i++) {
			Tab tab = tabs.get(i);
			if (tab.getName().equals(name)) {
				tab.setHidden(false);
				
				TabWidget widget = tabHost.getTabWidget();
				widget.getChildAt(i).setVisibility(View.VISIBLE);		
				
				tabHost.setCurrentTab(i);
				if(tab.getScrollViewForTab() != null){
					tab.getScrollViewForTab().scrollTo(0, 0);
				}
				return tab;
			}
		}
	}
	return null;
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:21,代码来源:TabGroup.java

示例9: onCreate

import android.widget.TabWidget; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	tabHost = getTabHost();
	
	layout = new LinearLayout(this, ComponentConstants.LAYOUT_ORIENTATION_VERTICAL);
	tabholder = new TabWidget(this);
	layout.add(tabholder);
	
	String classname = getClass().getName();
	int lastDot = classname.lastIndexOf('.');
	tabformName = classname.substring(lastDot + 1);
	Log.d(LOG_TAG, "TabForm " + tabformName + " got onCreate");
			
	$define();
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:18,代码来源:TabForm.java

示例10: createTabHost

import android.widget.TabWidget; //导入依赖的package包/类
public static TabHost createTabHost(Context context) {
    // Create the TabWidget (the tabs)
    TabWidget tabWidget = new TabWidget(context);
    tabWidget.setId(android.R.id.tabs);

    // Create the FrameLayout (the content area)
    FrameLayout frame = new FrameLayout(context);
    frame.setId(android.R.id.tabcontent);
    LinearLayout.LayoutParams frameLayoutParams = new LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
    frameLayoutParams.setMargins(4, 4, 4, 4);
    frame.setLayoutParams(frameLayoutParams);

    // Create the container for the above widgets
    LinearLayout tabHostLayout = new LinearLayout(context);
    tabHostLayout.setOrientation(LinearLayout.VERTICAL);
    tabHostLayout.addView(tabWidget);
    tabHostLayout.addView(frame);

    // Create the TabHost and add the container to it.
    TabHost tabHost = new TabHost(context, null);
    tabHost.addView(tabHostLayout);
    tabHost.setup();

    return tabHost;
}
 
开发者ID:b2renger,项目名称:PdDroidPublisher,代码行数:27,代码来源:PdDroidParty.java

示例11: setTabHostSelector

import android.widget.TabWidget; //导入依赖的package包/类
public static void setTabHostSelector(TabHost host, int selector) {
    if (host == null) {
        return;
    }
    TabWidget widget = host.getTabWidget();
    if (widget == null) {
        return;
    }
    for(int i = 0; i < widget.getChildCount(); i++) {
        View v = widget.getChildAt(i);
        if (v == null) {
            continue;
        }
        TextView tv = (TextView) v.findViewById(android.R.id.title);
        if (tv == null) {
            continue;
        }
        v.setBackgroundResource(selector);
    }
}
 
开发者ID:DanDits,项目名称:WhatsThat,代码行数:21,代码来源:UiStyleUtil.java

示例12: a

import android.widget.TabWidget; //导入依赖的package包/类
private void a(View view)
{
    android.view.ViewGroup.LayoutParams layoutparams = view.getLayoutParams();
    android.view.ViewParent viewparent = view.getParent();
    FrameLayout framelayout = new FrameLayout(i);
    if (view instanceof TabWidget)
    {
        View view1 = ((TabWidget)view).getChildTabViewAt(q);
        j = view1;
        ((ViewGroup)view1).addView(framelayout, new android.view.ViewGroup.LayoutParams(-1, -1));
        setVisibility(8);
        framelayout.addView(this);
        return;
    } else
    {
        ViewGroup viewgroup = (ViewGroup)viewparent;
        int i1 = viewgroup.indexOfChild(view);
        viewgroup.removeView(view);
        viewgroup.addView(framelayout, i1, layoutparams);
        framelayout.addView(view);
        setVisibility(8);
        framelayout.addView(this);
        viewgroup.invalidate();
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:27,代码来源:BadgeView.java

示例13: a

import android.widget.TabWidget; //导入依赖的package包/类
private void a(Context context, AttributeSet attributeset)
{
    TypedArray typedarray = context.obtainStyledAttributes(attributeset, new int[] {
        0x10100f3
    }, 0, 0);
    e = typedarray.getResourceId(0, 0);
    typedarray.recycle();
    super.setOnTabChangedListener(this);
    if (findViewById(0x1020013) == null)
    {
        LinearLayout linearlayout = new LinearLayout(context);
        linearlayout.setOrientation(1);
        addView(linearlayout, new android.widget.FrameLayout.LayoutParams(-1, -1));
        TabWidget tabwidget = new TabWidget(context);
        tabwidget.setId(0x1020013);
        tabwidget.setOrientation(0);
        linearlayout.addView(tabwidget, new android.widget.LinearLayout.LayoutParams(-1, -2, 0.0F));
        FrameLayout framelayout = new FrameLayout(context);
        framelayout.setId(0x1020011);
        linearlayout.addView(framelayout, new android.widget.LinearLayout.LayoutParams(0, 0, 0.0F));
        FrameLayout framelayout1 = new FrameLayout(context);
        b = framelayout1;
        b.setId(e);
        linearlayout.addView(framelayout1, new android.widget.LinearLayout.LayoutParams(-1, 0, 1.0F));
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:27,代码来源:FragmentTabHost.java

示例14: setUpTabs

import android.widget.TabWidget; //导入依赖的package包/类
private void setUpTabs() {
    List<TabModel> tabs = tabsToAdd();

    fragmentManager = getSupportFragmentManager();
    tabHost.setup(this, fragmentManager, android.R.id.tabcontent);
    for (int i = 0; i < tabs.size(); i ++){
        TabModel tab = tabs.get(i);
        tabHost.addTab(
                tabHost.newTabSpec(tab.getTag()).setIndicator(tab.getName(), null),
                tab.getFragmentClass(),
                tab.getFragmentArgs());
    }

    TabWidget widget = tabHost.getTabWidget();

    for (int i = 0; i < widget.getChildCount(); i++) {
        final TextView tv = (TextView) widget.getChildAt(i).findViewById(
                android.R.id.title);
        tv.setTextColor(this.getResources().getColorStateList(
                R.color.tab_selector));
        tv.setSingleLine(true);
        tv.setAllCaps(true);
    }
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:25,代码来源:BaseTabActivity.java

示例15: ensureHierarchy

import android.widget.TabWidget; //导入依赖的package包/类
private void ensureHierarchy(Context context)
{
    if (findViewById(0x1020013) == null)
    {
        LinearLayout linearlayout = new LinearLayout(context);
        linearlayout.setOrientation(1);
        addView(linearlayout, new android.widget.FrameLayout.LayoutParams(-1, -1));
        Object obj = new TabWidget(context);
        ((TabWidget) (obj)).setId(0x1020013);
        ((TabWidget) (obj)).setOrientation(0);
        linearlayout.addView(((View) (obj)), new android.widget.LinearLayout.LayoutParams(-1, -2, 0.0F));
        obj = new FrameLayout(context);
        ((FrameLayout) (obj)).setId(0x1020011);
        linearlayout.addView(((View) (obj)), new android.widget.LinearLayout.LayoutParams(0, 0, 0.0F));
        context = new FrameLayout(context);
        mRealTabContent = context;
        mRealTabContent.setId(mContainerId);
        linearlayout.addView(context, new android.widget.LinearLayout.LayoutParams(-1, 0, 1.0F));
    }
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:21,代码来源:FragmentTabHost.java


注:本文中的android.widget.TabWidget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。