當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。