當前位置: 首頁>>代碼示例>>Java>>正文


Java TabWidget.setStripEnabled方法代碼示例

本文整理匯總了Java中android.widget.TabWidget.setStripEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java TabWidget.setStripEnabled方法的具體用法?Java TabWidget.setStripEnabled怎麽用?Java TabWidget.setStripEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TabWidget的用法示例。


在下文中一共展示了TabWidget.setStripEnabled方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import android.widget.TabWidget; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
	this.mContext = context;
	LayoutInflater.from(context).inflate(R.layout.tabhost_title_head, this, true);
	mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
	setup();
	mTabWidget.setStripEnabled(false);
	initViewEvents();
	this.setBackgroundColor(Color.TRANSPARENT);
}
 
開發者ID:JasonFengIce,項目名稱:AndroidTVWidget,代碼行數:10,代碼來源:OpenTabHost.java

示例2: 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);
	widget.setStripEnabled(true);
	linearlayouts[position].setPressed(true);
	mTabHost.setCurrentTab(position);
	widget.setDescendantFocusability(oldFocusability);
}
 
開發者ID:samuelhehe,項目名稱:AppMarket,代碼行數:16,代碼來源:AtyHome2.java

示例3: onFinishInflate

import android.widget.TabWidget; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
    mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost);
    mTabHost.setup();
    for (final EmojiCategory.CategoryProperties properties
            : mEmojiCategory.getShownCategories()) {
        addTab(mTabHost, properties.mCategoryId);
    }
    mTabHost.setOnTabChangedListener(this);
    final TabWidget tabWidget = mTabHost.getTabWidget();
    tabWidget.setStripEnabled(mCategoryIndicatorEnabled);
    if (mCategoryIndicatorEnabled) {
        // On TabWidget's strip, what looks like an indicator is actually a background.
        // And what looks like a background are actually left and right drawables.
        tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId);
        tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId);
        tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId);
    }

    mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this);

    mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
    mEmojiPager.setAdapter(mEmojiPalettesAdapter);
    mEmojiPager.setOnPageChangeListener(this);
    mEmojiPager.setOffscreenPageLimit(0);
    mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
    mEmojiLayoutParams.setPagerProperties(mEmojiPager);

    mEmojiCategoryPageIndicatorView =
            (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
    mEmojiCategoryPageIndicatorView.setColors(
            mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground);
    mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);

    setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);

    final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
    mEmojiLayoutParams.setActionBarProperties(actionBar);

    // deleteKey depends only on OnTouchListener.
    mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete);
    mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
    mDeleteKey.setTag(Constants.CODE_DELETE);
    mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);

    // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on
    // {@link View.OnClickListener} as well as {@link View.OnTouchListener}.
    // {@link View.OnTouchListener} is used as the trigger of key-press, while
    // {@link View.OnClickListener} is used as the trigger of key-release which does not occur
    // if the event is canceled by moving off the finger from the view.
    // The text on alphabet keys are set at
    // {@link #startEmojiPalettes(String,int,float,Typeface)}.
    mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
    mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
    mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
    mAlphabetKeyLeft.setOnTouchListener(this);
    mAlphabetKeyLeft.setOnClickListener(this);
    mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
    mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
    mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
    mAlphabetKeyRight.setOnTouchListener(this);
    mAlphabetKeyRight.setOnClickListener(this);
    mSpacebar = findViewById(R.id.emoji_keyboard_space);
    mSpacebar.setBackgroundResource(mSpacebarBackgroundId);
    mSpacebar.setTag(Constants.CODE_SPACE);
    mSpacebar.setOnTouchListener(this);
    mSpacebar.setOnClickListener(this);
    mEmojiLayoutParams.setKeyProperties(mSpacebar);
    mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:71,代碼來源:EmojiPalettesView.java

示例4: onActivityCreated

import android.widget.TabWidget; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);
    iv_nav_indicator = (ImageView) mRootView.findViewById(R.id.tab_pager_nav_indicator);
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    indicatorWidth = dm.widthPixels / 3;

    LayoutParams cursor_Params = iv_nav_indicator.getLayoutParams();
    //Toast.makeText(getActivity(), "indicatorWidth is:"+indicatorWidth, 1).show();
    cursor_Params.width = indicatorWidth;
    iv_nav_indicator.setLayoutParams(cursor_Params);
    addresses = getActivity().getResources().getStringArray(R.array.dt_nav_tab_menu);
    mTabWidget = (TabWidget) mRootView.findViewById(R.id.tabWidget1);
    mTabWidget.setStripEnabled(false);
    mTextTabs[0] = new TextView(mContext);
    mTextTabs[0].setFocusable(true);
    mTextTabs[0].setText(addresses[0]);
    mTextTabs[0].setTextSize(20);
    mTextTabs[0].setGravity(Gravity.CENTER);
    //mTextTabs[0].setTextColor(getResources().getColorStateList(R.drawable.dt_rb_blue_bg));
    mTabWidget.addView(mTextTabs[0]);
    /* 
     * Listener必須在mTabWidget.addView()之後再加入,用於覆蓋默認的Listener,
     * mTabWidget.addView()中默認的Listener沒有NullPointer檢測。
     */
    mTextTabs[0].setOnClickListener(mTabClickListener);
    mTextTabs[1] = new TextView(mContext);
    mTextTabs[1].setFocusable(true);
    mTextTabs[1].setText(addresses[1]);
    mTextTabs[1].setTextSize(20);
    mTextTabs[1].setGravity(Gravity.CENTER);
    //mTextTabs[1].setTextColor(getResources().getColorStateList(R.drawable.dt_rb_blue_bg));
    mTabWidget.addView(mTextTabs[1]);
    mTextTabs[1].setOnClickListener(mTabClickListener);
    mTextTabs[2] = new TextView(mContext);
    mTextTabs[2].setFocusable(true);
    mTextTabs[2].setText(addresses[2]);
    mTextTabs[2].setTextSize(20);
    mTextTabs[2].setGravity(Gravity.CENTER);
    //mTextTabs[2].setTextColor(getResources().getColorStateList(R.drawable.dt_rb_blue_bg));
    mTabWidget.addView(mTextTabs[2]);
    mTextTabs[2].setOnClickListener(mTabClickListener);

    mViewPager = (ViewPager) mRootView.findViewById(R.id.viewPager1);
    mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(mPageChangeListener);
    mViewPager.setOffscreenPageLimit(2);

    mTabWidget.setCurrentTab(0);
    //mTabWidget.setOnFocusChangeListener(mTabChangeListener);
}
 
開發者ID:peterfuture,項目名稱:dttv-android,代碼行數:55,代碼來源:SlideTabsFragment.java

示例5: MaterialTabHost

import android.widget.TabWidget; //導入方法依賴的package包/類
public MaterialTabHost(Context context, AttributeSet attrs) {
    super(context, attrs);

    inflater = LayoutInflater.from(context);

    TypedValue outValue = new TypedValue();
    Resources.Theme theme = context.getTheme();

    // use ?attr/colorPrimary as background color
    theme.resolveAttribute(R.attr.colorPrimary, outValue, true);
    setBackgroundColor(outValue.data);

    // use ?attr/colorControlActivated as default indicator color
    theme.resolveAttribute(R.attr.colorControlActivated, outValue, true);
    colorControlActivated = outValue.data;

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialTabHost, 0, 0);
    int indicatorColor = a.getColor(R.styleable.MaterialTabHost_colorTabIndicator, colorControlActivated);
    a.recycle();

    // ColorDrawable on 2.x does not use getBounds() so use ShapeDrawable
    indicator = new ShapeDrawable();
    indicator.setColorFilter(indicatorColor, PorterDuff.Mode.SRC_ATOP);

    Resources res = context.getResources();
    indicatorHeight = res.getDimensionPixelSize(R.dimen.mth_tab_indicator_height);
    leftOffset = res.getDimensionPixelSize(R.dimen.mth_tab_left_offset);
    int tabHeight = res.getDimensionPixelSize(R.dimen.mth_tab_height);

    tabWidget = new TabWidget(context);
    tabWidget.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, tabHeight));
    tabWidget.setId(android.R.id.tabs);
    tabWidget.setStripEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        tabWidget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    }
    addView(tabWidget);

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

    setup();

    setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (listener != null) {
                listener.onTabSelected(Integer.valueOf(tabId));
            }
        }
    });

    float density = getResources().getDisplayMetrics().density;

    // set elevation for App bar
    // http://www.google.com/design/spec/what-is-material/objects-in-3d-space.html#objects-in-3d-space-elevation
    ViewCompat.setElevation(this, APP_TAB_ELEVATION * density);
}
 
開發者ID:yanzm,項目名稱:MaterialTabHost,代碼行數:61,代碼來源:MaterialTabHost.java

示例6: onCreate

import android.widget.TabWidget; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.demo_tab_view);

    mTabWidget = ( TabWidget) findViewById(R.id.tabWidget1);

    mTabWidget.setStripEnabled(false);
    mTabWidget.setFocusable(false);

    for (int i = 0; i < mTabWidget.getChildCount(); i++) {
        mTabWidget.getChildAt(i).setOnClickListener(mTabClickListener);
        mTabWidget.getChildAt(i).setOnFocusChangeListener(mTabFocusListener);
    }

    mViewPager = (ViewPager) findViewById(R.id.viewPager1);
    mPagerAdapter = new MyPagerAdapter();
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(mPageChangeListener);

    mPagerAdapter.notifyDataSetChanged();


    mTabWidget.focusCurrentTab(0);

    BorderView borderView = new BorderView(this);

    borderView.setBackgroundResource(R.drawable.border_highlight);
    borderView.attachTo(mTabWidget);

    BorderView borderView2 = new BorderView(this);

     borderView2.setBackgroundResource(R.drawable.border_white_light_10);
    borderView2.attachTo(mViewPager);

}
 
開發者ID:evilbinary,項目名稱:TvWidget,代碼行數:38,代碼來源:DemoTabActivity.java


注:本文中的android.widget.TabWidget.setStripEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。