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.yktx.check.widget.OldPagerSlidingTabStrip.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.ja v a  2  s. com*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTabTextSize);
            }
        } else if (v instanceof LinearLayout) {
            LinearLayout tab = (LinearLayout) v;
            TextView text = (TextView) tab.findViewById(R.id.text);
            text.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            text.setTypeface(tabTypeface, tabTypefaceStyle);
            text.setTextColor(tabTextColor);

            ImageView image = (ImageView) tab.findViewById(R.id.image);
            image.setImageResource(((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
            // 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) {
                    text.setAllCaps(true);
                } else {
                    text.setText(text.getText().toString().toUpperCase(locale));
                }
            }

            if (i == selectedPosition) {
                text.setTextColor(selectedTabTextColor);
                text.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTabTextSize);
                image.setImageResource(((IconTabProvider) pager.getAdapter()).getSelectPageIconResId(i));
            }

        }
    }

}

From source file:org.openlmis.core.view.widget.MMIAInfoList.java

private void addItemView(BaseInfoItem item, boolean isHeaderView, final int position) {
    View view = layoutInflater.inflate(R.layout.item_mmia_info, this, false);
    TextView tvName = (TextView) view.findViewById(R.id.tv_name);
    EditText etValue = (EditText) view.findViewById(R.id.et_value);

    if (isHeaderView) {
        tvName.setText(R.string.label_mmia_info_header_name);
        etValue.setText(getResources().getString(R.string.label_total_mmia).toUpperCase());
        etValue.setEnabled(false);/* www .  j  a  va 2  s.  co  m*/
        etValue.setGravity(Gravity.CENTER);
        view.setBackgroundResource(R.color.color_mmia_info_name);
    } else {
        tvName.setText(item.getName());
        editTexts.add(etValue);
        etValue.setText(item.getValue());

        if (isTotalPatient(item)) {
            totalPatientsItem = item;

            totalPatientsView = etValue;
            totalPatientsView.setEnabled(false);
        } else {
            etValue.addTextChangedListener(new EditTextWatcher(item));
        }
        setTotalViewBackground(item, etValue);
    }
    addView(view);

    etValue.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                if ((position + 1) < editTexts.size()) {
                    editTexts.get(position + 1).requestFocus();
                    return true;
                }
            }
            return false;
        }
    });

}

From source file:net.coding.program.common.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 (i == 0) {
                tab.setTextColor(getTextSelectedColor());
            }/*  ww  w .j  a  va2 s  . com*/
            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.com.zzwfang.view.indicator.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);/*  w ww  . j a  v a2  s.c o  m*/
        } 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 (pager.getCurrentItem() == i) {
                tab.setTextColor(tabTextColor);
            } else {
                tab.setTextColor(tabUnselectedTextColor);
            }

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

}

From source file:com.chenl.widgets.flippablestackview.indicator.OrientedPagerSlidingTabLayout.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View childView = tabsContainer.getChildAt(i);
        if (tabBackgroundResId == -1) {
            childView.setBackgroundDrawable(mTabBackgroundRes);
        } else {//ww w.j av  a  2  s .  c  o  m
            childView.setBackgroundResource(tabBackgroundResId);
        }
        if (childView instanceof TextView) {
            TextView tab = (TextView) childView;
            tab.setTextSize(tabTextSize);
            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 source file:com.summer.helper.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        ///*w  w w  .j  a  va 2 s.c  o m*/
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, 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.xujun.funapp.widget.TabPagerIndicator.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 && pager.getCurrentItem() == 0) {
                tab.setTextColor(tabSelectTextColor);
            } else {
                tab.setTextColor(tabTextColor);
            }//from   www . j  av a 2 s .c o 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.nadmm.airports.FragmentBase.java

protected void makeRowClickable(View row, Object tag) {
    row.setTag(tag);/* w w w.ja v a2s . c o m*/
    row.setOnClickListener(mOnRowClickListener);
    int backgroundResource = UiUtils.getSelectableItemBackgroundResource(getActivity());
    row.setBackgroundResource(backgroundResource);
}

From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java

public void initTabStyles() {
    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  a v  a2s . co  m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                if (oldTab != null) {
                    oldTab.setSelected(false);
                    ((TextView) oldTab).setTextColor(tabTextColor);
                }
                oldTab = tab;
                tab.setSelected(true);
            }
        }
    }
}

From source file:com.cssweb.android.quote.QHSCGridActivity.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;
        localView1.setBackgroundResource(l);
    }//from  w w  w .  j  a v a  2s.c  o m
    LinearLayout localLinearLayout2 = this.mLinerLock;
    Integer localInteger2 = Integer.valueOf(paramInt);
    View localView2 = localLinearLayout2.findViewWithTag(localInteger2);
    if (localView2 != null) {
        int i1 = this.residSelColor;
        localView2.setBackgroundColor(i1);
    }

    if (true) {
        LinearLayout localLinerLock = this.mLinerLock2;
        Integer localLockInteger = Integer.valueOf(this.m_nPos);
        View localLockView = localLinerLock.findViewWithTag(localLockInteger);
        if (localLockView != null) {
            int l = this.residCol;
            localLockView.setBackgroundResource(l);
        }
        LinearLayout localLinerLock2 = this.mLinerLock2;
        Integer localLockInteger2 = Integer.valueOf(paramInt);
        View localLockView2 = localLinerLock2.findViewWithTag(localLockInteger2);
        if (localLockView2 != null) {
            int i1 = this.residSelColor;
            localLockView2.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;

    if (null != stringList && stringList.size() > paramInt && null != temp2[m_nPos - 1]
            && !"".equals(temp2[m_nPos - 1]) && null != temp1[m_nPos - 1] && !"".equals(temp1[m_nPos - 1])
            && temp1[m_nPos - 1].length() > 2) {

        Log.i("tag", "stringList.length" + stringList.size() + " : paramInt : " + paramInt);

        String[] data = stringList.get(paramInt - 1);
        String market = data[data.length - 2];
        cssStock = new CssStock();
        cssStock.setStkcode(temp1[m_nPos - 1].substring(2)); // 
        cssStock.setStkname(temp2[m_nPos - 1]);
        cssStock.setMarket(market);
    }
    // this.cssStock = list.get(paramInt - 1);
}