Example usage for android.view View setBackgroundResource

List of usage examples for android.view View setBackgroundResource

Introduction

In this page you can find the example usage for android.view View setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:com.example.jingzhongjie.tabbarviewtest.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, Typeface.NORMAL);
            tab.setTextColor(defaultTextColor);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from w w w .  ja v  a2  s. com*/
            }
        }
    }
}

From source file:com.jumeng.shop.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from   w w w. ja  v a 2 s  .  c o  m*/
            }
        }
    }
}

From source file:com.scut.gof.coordinator.main.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/* w ww. j a v a  2s .co m*/
            }
        }
    }

}

From source file:com.gc.materialdesign.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            // tab.setBackgroundResource(R.drawable.tab_selector);
            tab.setTextColor(tabTextColor);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from  w  w  w. j  av a 2s . c o m*/
            }
        }
    }
}

From source file:com.anniu.shandiandaojia.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            //TODO tab?   ????
            tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            if (i == currentPosition) {
                tab.setTextColor(tabTextColorSelected);
            } else {
                tab.setTextColor(tabTextColor);
            }//w  w  w  .j  a  v  a2  s  .c  om

            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:cn.bingoogol.tabhost.ui.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            // setAllCaps() is only available from API 14, so the upper case is made
            // manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from ww  w.j  ava 2 s. co m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.gc.materialdesign.views.PagerSlidingTabStrip.java

public void updateTabStyles(int position) {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == position) {
                //  tab.setBackgroundResource(R.drawable.selected_tab_bg);
                tab.setTextColor(tabSelectedTextColor);
                tab.setBackgroundColor(tabSelectedBgColor);
            } else {
                //  tab.setBackgroundColor(getResources().getColor(android.R.color.transparent));
                tab.setTextColor(tabTextColor);
                tab.setBackgroundColor(tabBgColor);
            }/* www . j  a v a2s  . co m*/
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.geeya.wifitv.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == 0)
                tab.setTextColor(0xfffba534);
            else/*from   www . j a  v  a 2 s .  c  o  m*/
                tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:in.shick.diode.common.Common.java

public static void updateNextPreviousButtons(ListActivity act, View nextPreviousView, String after,
        String before, int count, RedditSettings settings, OnClickListener downloadAfterOnClickListener,
        OnClickListener downloadBeforeOnClickListener) {
    boolean shouldShow = after != null || before != null;
    Button nextButton = null;/*from   ww  w .  j  av a  2 s . c o m*/
    Button previousButton = null;

    // If alwaysShowNextPrevious, use the navbar
    if (settings.isAlwaysShowNextPrevious()) {
        nextPreviousView = act.findViewById(R.id.next_previous_layout);
        if (nextPreviousView == null) {
            return;
        }
        View nextPreviousBorder = act.findViewById(R.id.next_previous_border_top);

        if (shouldShow) {
            if (nextPreviousBorder != null) {
                if (Util.isLightTheme(settings.getTheme())) {
                    nextPreviousView.setBackgroundResource(android.R.color.background_light);
                    nextPreviousBorder.setBackgroundResource(R.color.black);
                } else {
                    nextPreviousBorder.setBackgroundResource(R.color.white);
                }
                nextPreviousView.setVisibility(View.VISIBLE);
            }
            // update the "next 25" and "prev 25" buttons
            nextButton = (Button) act.findViewById(R.id.next_button);
            previousButton = (Button) act.findViewById(R.id.previous_button);
        } else {
            nextPreviousView.setVisibility(View.GONE);
        }
    }
    // Otherwise we are using the ListView footer
    else {
        if (nextPreviousView == null) {
            return;
        }
        if (shouldShow && nextPreviousView.getVisibility() != View.VISIBLE) {
            nextPreviousView.setVisibility(View.VISIBLE);
        } else if (!shouldShow && nextPreviousView.getVisibility() == View.VISIBLE) {
            nextPreviousView.setVisibility(View.GONE);
        }
        // update the "next 25" and "prev 25" buttons
        nextButton = (Button) nextPreviousView.findViewById(R.id.next_button);
        previousButton = (Button) nextPreviousView.findViewById(R.id.previous_button);
    }
    if (nextButton != null) {
        if (after != null) {
            nextButton.setVisibility(View.VISIBLE);
            nextButton.setOnClickListener(downloadAfterOnClickListener);
        } else {
            nextButton.setVisibility(View.INVISIBLE);
        }
    }
    if (previousButton != null) {
        if (before != null && count != Constants.DEFAULT_THREAD_DOWNLOAD_LIMIT) {
            previousButton.setVisibility(View.VISIBLE);
            previousButton.setOnClickListener(downloadBeforeOnClickListener);
        } else {
            previousButton.setVisibility(View.INVISIBLE);
        }
    }
}

From source file:com.contentful.discovery.ui.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we
            // are on a pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//w ww.j  a v a 2  s  . c om
            }
        }
    }
}