Example usage for android.widget TextView setBackgroundResource

List of usage examples for android.widget TextView setBackgroundResource

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:com.jve.util.view.slidedatetimepicker.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  ww w  .  jav  a2 s .c  o m
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:agilec.ikeaswipe.utils.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   w  ww.  jav  a 2 s.  c om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    // TODO: Use setCustomTabView(int, int) instead of the following modification to createDefaultTabView.
    // Get the screen size.
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;

    // Get the number of tabs in the viewPager.
    final PagerAdapter adapter = mViewPager.getAdapter();

    // Set the width of the textViews to fill up the entire screen.
    textView.setWidth(width / adapter.getCount());

    return textView;
}

From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int, int)}.
 *//*from w  w w. j a  va2s . c  om*/
protected View createDefaultTabView(Context context, int type) {
    if (type == 0) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));

        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
        textView.setAllCaps(true);

        int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        textView.setPadding(padding, padding, padding, padding);

        return textView;
    } else {
        ImageView iconView = new ImageView(context);
        int iconSize = (int) (TAB_VIEW_ICON_SIZE_DIPS * getResources().getDisplayMetrics().density);
        int padding = (int) (TAB_VIEW_ICON_PADDING_DIPS * getResources().getDisplayMetrics().density);

        iconView.setLayoutParams(new LinearLayout.LayoutParams(iconSize + padding, iconSize + padding));
        iconView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        iconView.setPadding(padding, padding, padding, padding);

        return iconView;
    }
}

From source file:com.ltf.mytoolslibrary.viewbase.viewPagerGuidanceActivityMyLib.SpringIndicator.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void addTabItems() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(20, 20);
    tabs = new ArrayList<>();
    layoutParams.setMargins(15, 0, 15, 0);
    for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
        TextView textView = new TextView(getContext());
        if (viewPager.getAdapter().getPageTitle(i) != null) {
            textView.setText(viewPager.getAdapter().getPageTitle(i));
        }//from  w  ww.j a  va 2s. com
        textView.setGravity(Gravity.CENTER);
        //            textView.setBackground(getResources().getDrawable(R.drawable.steward_msg_red));
        textView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.circle_orange));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(getResources().getColor(textColorId));
        if (textBgResId != 0) {
            textView.setBackgroundResource(textBgResId);
        }
        textView.setLayoutParams(layoutParams);
        final int position = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tabClickListener == null || tabClickListener.onTabClick(position)) {
                    viewPager.setCurrentItem(position);
                }
            }
        });
        tabs.add(textView);
        tabContainer.addView(textView);
    }
}

From source file:org.rm3l.ddwrt.fragments.DDWRTBaseFragment.java

@NotNull
private ViewGroup getLayout() {
    @NotNull//from w w  w.  ja v  a  2  s .c  om
    final LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    params.setMargins(margin, margin, margin, margin);

    boolean atLeastOneTileAdded = false;

    final SherlockFragmentActivity sherlockActivity = getSherlockActivity();
    if (this.fragmentTiles != null && !this.fragmentTiles.isEmpty()) {

        @NotNull
        final List<CardView> cards = new ArrayList<CardView>();

        final CardView.LayoutParams cardViewLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);

        final int themeBackgroundColor = getThemeBackgroundColor(sherlockActivity, router.getUuid());

        final boolean isThemeLight = isThemeLight(sherlockActivity, themeBackgroundColor);

        for (@NotNull
        final DDWRTTile ddwrtTile : this.fragmentTiles) {
            @Nullable
            final ViewGroup viewGroupLayout = ddwrtTile.getViewGroupLayout();
            atLeastOneTileAdded |= (viewGroupLayout != null);

            if (viewGroupLayout == null) {
                continue;
            }

            if (isThemeLight) {
                ((TextView) viewGroupLayout.findViewById(ddwrtTile.getTileTitleViewId()))
                        .setTextColor(getResources().getColor(android.R.color.holo_blue_dark));
            }

            //Detach this from Parent
            final ViewParent parent = viewGroupLayout.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(viewGroupLayout);
            }

            viewGroupLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));

            final CardView cardView = new CardView(sherlockActivity);
            cardView.setOnClickListener(ddwrtTile);
            cardView.setLayoutParams(cardViewLayoutParams);
            cardView.setCardBackgroundColor(themeBackgroundColor);
            //Add padding to CardView on v20 and before to prevent intersections between the Card content and rounded corners.
            cardView.setPreventCornerOverlap(true);
            //Add padding in API v21+ as well to have the same measurements with previous versions.
            cardView.setUseCompatPadding(true);

            cardView.addView(viewGroupLayout);

            cards.add(cardView);
        }

        atLeastOneTileAdded = (!cards.isEmpty());

        Log.d(LOG_TAG, "atLeastOneTileAdded: " + atLeastOneTileAdded + ", rows: " + cards.size());

        if (atLeastOneTileAdded) {
            //Drop Everything
            //                viewGroup.removeAllViews();

            mLayout = (LinearLayout) viewGroup.findViewById(R.id.tiles_container_scrollview_layout);

            for (@NotNull
            final CardView card : cards) {
                //                    mTableLayout.removeView(row);
                mLayout.addView(card);
            }

        }

        ((ScrollView) viewGroup).setFillViewport(true);
    }

    if (viewGroup == null || !atLeastOneTileAdded) {
        viewGroup = new FrameLayout(sherlockActivity);
        @NotNull
        final TextView view = new TextView(sherlockActivity);
        view.setGravity(Gravity.CENTER);
        view.setText(getResources().getString(R.string.no_data));
        view.setBackgroundResource(R.drawable.background_card);
        view.setLayoutParams(params);

        viewGroup.addView(view);
    }

    viewGroup.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    viewGroup.setLayoutParams(params);

    return viewGroup;

}

From source file:org.tomahawk.tomahawk_android.fragments.ContentHeaderFragment.java

/**
 * Show a content header. A content header provides information about the current Collection
 * object that the user has navigated to. Like an AlbumArt image with the {@link
 * org.tomahawk.libtomahawk.collection.Album}s name, which is shown at the top of the listview,
 * if the user browses to a particular {@link org.tomahawk.libtomahawk.collection.Album} in his
 * {@link org.tomahawk.libtomahawk.collection.UserCollection}.
 *
 * @param item the Collection object's information to show in the header view
 *//*ww w .  jav a 2 s. c  o  m*/
protected void showContentHeader(final Object item) {
    if (getView() == null) {
        Log.e(TAG, "Couldn't setup content header, because getView() is null!");
        return;
    }

    boolean isPagerFragment = this instanceof PagerFragment;

    //Inflate content header
    int stubResId;
    int inflatedId;
    if (item instanceof User) {
        stubResId = isPagerFragment ? R.id.content_header_user_pager_stub : R.id.content_header_user_stub;
        inflatedId = isPagerFragment ? R.id.content_header_user_pager : R.id.content_header_user;
    } else {
        if (mHeaderScrollableHeight > 0) {
            stubResId = isPagerFragment ? R.id.content_header_pager_stub : R.id.content_header_stub;
            inflatedId = isPagerFragment ? R.id.content_header_pager : R.id.content_header;
        } else {
            stubResId = isPagerFragment ? R.id.content_header_static_pager_stub
                    : R.id.content_header_static_stub;
            inflatedId = isPagerFragment ? R.id.content_header_static_pager : R.id.content_header_static;
        }
    }
    final View contentHeader = ViewUtils.ensureInflation(getView(), stubResId, inflatedId);
    contentHeader.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;

    //Now we fill the added views with data and inflate the correct imageview_grid depending on
    //what we need
    final int gridOneStubId = isPagerFragment ? R.id.imageview_grid_one_pager_stub
            : R.id.imageview_grid_one_stub;
    final int gridOneResId = isPagerFragment ? R.id.imageview_grid_one_pager : R.id.imageview_grid_one;
    if (item instanceof Integer) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageView, (Integer) item);
    } else if (item instanceof String) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageView, (String) item);
    } else if (item instanceof ColorDrawable) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        imageView.setImageDrawable((ColorDrawable) item);
    } else if (mHeaderScrollableHeight > 0) {
        View.OnClickListener moreButtonListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentUtils.showContextMenu((TomahawkMainActivity) getActivity(), item, mCollection.getId(),
                        false, mHideRemoveButton);
            }
        };
        if (item instanceof Album) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Album) item).getImage(),
                    Image.getLargeImageSize(), false);
            View moreButton = getView().findViewById(R.id.more_button);
            moreButton.setOnClickListener(moreButtonListener);
        } else if (item instanceof Artist) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Artist) item).getImage(),
                    Image.getLargeImageSize(), true);
            View moreButton = getView().findViewById(R.id.more_button);
            moreButton.setOnClickListener(moreButtonListener);
        } else if (item instanceof Playlist) {
            ViewHolder.fillView(getView(), (Playlist) item,
                    mHeaderNonscrollableHeight + mHeaderScrollableHeight, isPagerFragment);
            View moreButton = getView().findViewById(R.id.more_button);
            moreButton.setOnClickListener(moreButtonListener);
        } else if (item instanceof Query) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Query) item).getImage(),
                    Image.getLargeImageSize(), ((Query) item).hasArtistImage());
            View moreButton = getView().findViewById(R.id.more_button);
            moreButton.setOnClickListener(moreButtonListener);
        }
    } else {
        if (item == null) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            imageView.setImageDrawable(
                    new ColorDrawable(getResources().getColor(R.color.userpage_default_background)));
        } else if (item instanceof Image) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageUtils.loadBlurredImageIntoImageView(TomahawkApp.getContext(),
                    (ImageView) v.findViewById(R.id.imageview1), (Image) item, Image.getSmallImageSize(),
                    R.color.userpage_default_background);
        } else if (item instanceof User) {
            User.getSelf().done(new DoneCallback<User>() {
                @Override
                public void onDone(final User user) {
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            boolean showFollowing = false;
                            boolean showNotFollowing = false;
                            if (mShowFakeFollowing || mShowFakeNotFollowing) {
                                showFollowing = mShowFakeFollowing;
                                showNotFollowing = mShowFakeNotFollowing;
                            } else if (!user.isOffline()) {
                                showFollowing = item != user && user.getFollowings() != null
                                        && user.getFollowings().containsKey(item);
                                showNotFollowing = item != user && (user.getFollowings() == null
                                        || !user.getFollowings().containsKey(item));
                            }
                            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
                            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
                            ImageUtils.loadBlurredImageIntoImageView(TomahawkApp.getContext(),
                                    (ImageView) v.findViewById(R.id.imageview1), ((User) item).getImage(),
                                    Image.getSmallImageSize(), R.color.userpage_default_background);
                            ImageUtils.loadUserImageIntoImageView(TomahawkApp.getContext(),
                                    (ImageView) contentHeader.findViewById(R.id.userimageview1), (User) item,
                                    Image.getSmallImageSize(),
                                    (TextView) contentHeader.findViewById(R.id.usertextview1));
                            TextView textView = (TextView) contentHeader.findViewById(R.id.textview1);
                            textView.setText(((User) item).getName().toUpperCase());
                            TextView followButton = (TextView) contentHeader.findViewById(R.id.followbutton1);
                            if (showFollowing) {
                                followButton.setVisibility(View.VISIBLE);
                                followButton.setBackgroundResource(
                                        R.drawable.selectable_background_button_green_filled);
                                followButton.setOnClickListener(mFollowButtonListener);
                                followButton.setText(TomahawkApp.getContext()
                                        .getString(R.string.content_header_following).toUpperCase());
                            } else if (showNotFollowing) {
                                followButton.setVisibility(View.VISIBLE);
                                followButton
                                        .setBackgroundResource(R.drawable.selectable_background_button_green);
                                followButton.setOnClickListener(mFollowButtonListener);
                                followButton.setText(TomahawkApp.getContext()
                                        .getString(R.string.content_header_follow).toUpperCase());
                            } else {
                                followButton.setVisibility(View.GONE);
                            }
                        }
                    });
                }
            });
        }
    }
}

From source file:com.example.rachid.myapplication.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  www  .ja  v  a 2s.c  o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    // AADIDO: Ajustar pantalla
    // ---------------------------------------------------------------------------------------
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);
    // ---------------------------------------------------------------------------------------

    return textView;
}

From source file:com.quran.labs.androidquran.widgets.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* ww w . j ava2  s .  c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setSingleLine();
    textView.setTextColor(mUnselectedTabColor);

    // If we're running on Honeycomb or newer, then we can use the Theme's
    // selectableItemBackground to ensure that the View has a pressed state
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = mTabPadding;
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.angel.topic.Widget.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   ww  w.j a v  a2 s  .c  om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setWidth(screenX);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.larry.miplayer.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  www .jav a  2 s.c  o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);

    /*********** BEGIN OF MY CODE*/
    /* Set color to white */
    textView.setTextColor(Color.WHITE);
    /*********** END OF MY CODE*/

    textView.setPadding(padding, padding, padding, padding);

    return textView;
}