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:asu.edu.msse.gpeddabu.moviedescriptions.MovieListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {/*from ww w  . j  a v a2s . com*/
    final String childText = (String) getChild(groupPosition, childPosition);
    if (convertView == null) {
        android.util.Log.d(this.getClass().getSimpleName(), "in getChildView null so creating new view");
        LayoutInflater inflater = (LayoutInflater) this.parent
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.movie_list, null);
    }
    TextView txtListChild = (TextView) convertView.findViewById(R.id.movieTitle);
    convertView.setOnTouchListener(this);
    convertView.setBackgroundResource(R.color.light_blue);
    txtListChild.setText(childText);
    return convertView;

}

From source file:com.anjuke.library.uicomponent.slidingtab.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        if (shouldExpand) {
            v.setLayoutParams(expandedTabLayoutParams);
        } else {// ww  w. j  av a2 s .c o  m
            v.setLayoutParams(defaultTabLayoutParams);
        }
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);
        } else {
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }

        if (v instanceof TextView) {

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

            if (i == pager.getCurrentItem() && selectedTextColor != 0) {
                tab.setTextColor(selectedTextColor);// add by TomkeyZhang
            } else {
                tab.setTextColor(tabTextColor);
            }
        }

    }

}

From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        View vs = null;// w ww  .j av  a2 s  .  c  o m
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof LinearLayout) {
            vs = ((LinearLayout) v).getChildAt(0);
        }

        if (v instanceof LinearLayout) {
            v = ((LinearLayout) v).getChildAt(1);
        }

        if (v instanceof TextView) {

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

            // 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));
                }
            }
            if (i == selectedTabPosition) {
                tab.setBackgroundColor(selectedTabBagC);
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
            }
        }
        if (null != vs) {
            if (vs instanceof ImageView) {
                ImageView ico = (ImageView) vs;
                if (i == 0) {
                    ico.setImageResource(icoColor);
                } else {
                    ico.setImageResource(icoColor1);
                }

                // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
                // pre-ICS-build
                if (i == selectedTabPosition) {
                    ico.setImageResource(selectedIcoColor);
                    if (i == 0) {
                        ico.setImageResource(selectedIcoColor);
                    } else {
                        ico.setImageResource(selectedIcoColor1);
                    }

                }
            }

        }
    }
}

From source file:com.mZone.epro.common.view.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;//from   ww  w  .ja v  a  2  s.  c  o  m

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            TypedValue outValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
            tabView.setBackgroundResource(outValue.resourceId);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);

            if (mTabViewLayoutId == R.layout.launch_home_fragment_tabhost_tabwidget) {
                ImageView iconView = (ImageView) tabView.findViewById(R.id.tabwidget_imageview);
                iconView.setImageResource(mCustomTabDelegate.getIconId(i, 0));
            }
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);
        tabViewArray.add(tabView);
        mTabStrip.addView(tabView);
    }
}

From source file:com.gqp.duoduo.view.SettlementView.java

private void bindData() {

    viewModel.bindContent(new Action1<Settlement.SettleMessageEntity>() {
        @Override/*from w  w w.  j a v  a 2  s  .  c o m*/
        public void call(Settlement.SettleMessageEntity deliverModels) {

            settleMessageEntity = deliverModels;
            moneyText.setText("" + settleMessageEntity.getSettelmentTotal().get("goodstotalamount"));

            if (deliverModels != null) {
                mList = deliverModels.getSettelment();
                dataLayout.setVisibility(View.VISIBLE);
                noDataLayout.setVisibility(View.GONE);

                container.removeAllViews();

                LayoutInflater inflater = LayoutInflater.from(getContext());

                View headerView = inflater.inflate(R.layout.common_item_hearder_layout, null);
                ((TextView) headerView.findViewById(R.id.common_item_01)).setText("??");
                ((TextView) headerView.findViewById(R.id.common_item_02)).setText("?");
                headerView.setBackgroundResource(R.color.gray_whiter);
                container.addView(headerView);
                View headdivider = new View(getContext());
                headdivider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                headdivider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                container.addView(headdivider);

                int index = 0;
                for (Settlement.MarketSettleEntity marketModel : mList) {

                    View view = inflater.inflate(R.layout.common_item_layout, null);
                    ViewMarketItemHolder holder = new ViewMarketItemHolder(view);
                    holder.bind(marketModel, index);
                    container.addView(view);

                    View divider = new View(getContext());
                    divider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                    divider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                    container.addView(divider);
                    index++;
                }
                if (mList != null && mList.size() > 0) {
                    View footerdivider = new View(getContext());
                    footerdivider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                    footerdivider.setBackgroundColor(Color.parseColor("#ededed"));
                    container.addView(footerdivider);
                }
                int sIndex = 0;
                List<CommonItem> tmpList = formatData(deliverModels.getSettelmentTotal());
                for (CommonItem commonItem : tmpList) {

                    View view = inflater.inflate(R.layout.common_item_hearder_layout, null);
                    ViewItemHolder holder = new ViewItemHolder(view);
                    holder.bind(commonItem, index);
                    container.addView(view);
                    View divider = new View(getContext());
                    divider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                    divider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                    container.addView(divider);
                    if (sIndex == 0) {
                        View footerView01 = new View(getContext());
                        footerView01.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                        footerView01.setBackgroundResource(R.color.gray_whiter);
                        container.addView(footerView01);
                        View viewitem = inflater.inflate(R.layout.common_item_header_layout, null);
                        ViewItemHeaderHolder holderitem = new ViewItemHeaderHolder(viewitem);
                        holderitem.bind("?", index);
                        container.addView(viewitem);
                        View divider01 = new View(getContext());
                        divider01.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                        divider01.setBackgroundColor(Color.parseColor("#DDDDDD"));
                        container.addView(divider01);
                    }
                    if (sIndex <= 2) {
                        if (sIndex == 2) {
                            View footerView01 = new View(getContext());
                            footerView01
                                    .setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                            footerView01.setBackgroundResource(R.color.gray_whiter);
                            container.addView(footerView01);

                        }
                    }
                    if (sIndex > 2 && sIndex <= 6) {
                        if (sIndex == 6) {
                            View footerView01 = new View(getContext());
                            footerView01
                                    .setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                            footerView01.setBackgroundResource(R.color.gray_whiter);
                            container.addView(footerView01);
                        }
                    }
                    sIndex++;
                }

            } else {
                dataLayout.setVisibility(View.GONE);
                noDataLayout.setVisibility(View.VISIBLE);
                container.setVisibility(View.GONE);
            }

        }
    });

}

From source file:com.yomii.view.PagerSlidingTab.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);

        if (tabCount == 1)
            v.setBackgroundResource(tabBackgroundResId);
        else if (i == 0) {
            v.setBackgroundResource(firstTabBackgroundResId);
            v.setSelected(true);/*from   www.  j  a  v  a2 s .  c o m*/
        } else if (i == tabCount - 1)
            v.setBackgroundResource(lastTabBackgroundResId);
        else
            v.setBackgroundResource(tabBackgroundResId);

        if (shouldExpand) {
            //v.setPadding(0, 0, 0, 0);
            tabsContainer.setPadding(tabPadding, 0, tabPadding, 0);
        } else {
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(i == 0 ? indicatorColor : 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:com.qingsongchou.library.widget.tab.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(dipToPx(getContext(), 18), v.getPaddingTop(), dipToPx(getContext(), 4),
                v.getPaddingBottom());// w  ww  .  j  a va 2  s  .co  m
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            //                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabNormalTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }
            }
        }
    }
}

From source file:net.yaly.ViewPagerDoubleIndicator.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.vpdi_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*from   w w  w.  ja  v a 2s. c  o  m*/
            }
        }
    }
}

From source file:com.messi.cantonese.study.views.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        /**4???**/
        v.setLayoutParams(defaultTabLayoutParams);
        //         v.setLayoutParams(expandedTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);//from w w w . j a va2 s. com
        } else {
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }

        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 source file:com.cssweb.android.base.QuoteGridActivity.java

public void setSelectRow(int paramInt) throws Exception {
    LinearLayout localLinearLayout1 = this.mLinerLock;
    Integer localInteger1 = Integer.valueOf(this.m_nPos);
    View localView1 = localLinearLayout1.findViewWithTag(localInteger1);
    if (localView1 != null) {
        int l = this.residCol;
        //         int l = this.residSelColor;
        localView1.setBackgroundResource(l);
    }/*  ww w . j a  v a  2s .  c om*/
    LinearLayout localLinearLayout2 = this.mLinerLock;
    Integer localInteger2 = Integer.valueOf(paramInt);
    View localView2 = localLinearLayout2.findViewWithTag(localInteger2);
    if (localView2 != null) {
        int i1 = this.residSelColor;
        localView2.setBackgroundColor(i1);
    }

    LinearLayout localLinearLayout3 = this.mLinerHScroll;
    Integer localInteger3 = Integer.valueOf(this.m_nPos);
    LinearLayout localLinearLayout4 = (LinearLayout) localLinearLayout3.findViewWithTag(localInteger3);

    if (localLinearLayout4 != null) {
        int i3 = localLinearLayout4.getChildCount();
        for (int i = 0; i < i3; i++) {
            View localView3 = localLinearLayout4.getChildAt(i);
            int i0 = 0;
            if (i == i3 - 1)
                i0 = this.residScrollCol[2];
            else if (i == 13)
                i0 = this.residScrollCol[1];
            else if (i % 2 == 0)
                i0 = this.residScrollCol[0];
            else
                i0 = this.residScrollCol[1];
            localView3.setBackgroundResource(i0);
        }
    }

    LinearLayout localLinearLayout5 = this.mLinerHScroll;
    Integer localInteger4 = Integer.valueOf(paramInt);
    LinearLayout localLinearLayout6 = (LinearLayout) localLinearLayout5.findViewWithTag(localInteger4);
    if (localLinearLayout6 != null) {
        int i4 = this.residSelColor;
        localLinearLayout6.setBackgroundColor(i4);
    }
    int i6 = localLinearLayout6.getChildCount();
    for (int i = 0; i < i6; i++) {
        View localView6 = localLinearLayout6.getChildAt(i);
        int i10 = this.residSelColor;
        localView6.setBackgroundColor(i10);
    }

    this.m_nPos = paramInt;
    this.cssStock = list.get(paramInt - 1);
}