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:brostore.maquillage.custom.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {
            setTextViewStyle(v);//ww  w  .  j ava2 s .  com
        } else if (v instanceof LinearLayout) {
            if (((LinearLayout) v).getChildCount() > 0
                    && ((LinearLayout) v).getChildAt(0) instanceof TextView) {
                setTextViewStyle(((LinearLayout) v).getChildAt(0));
            }
        }
    }
}

From source file:com.wudoumi.batter.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);
            updateTabTextSize(tab);//from w ww . jav a 2 s . c om
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(textColor);

            // 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:co.nerdart.ourss.adapter.FeedsCursorAdapter.java

@Override
protected void bindChildView(View view, Context context, Cursor cursor) {
    view.findViewById(R.id.indicator).setVisibility(View.INVISIBLE);

    TextView textView = ((TextView) view.findViewById(android.R.id.text1));
    long feedId = cursor.getLong(idPosition);
    if (feedId == mSelectedFeedId) {
        view.setBackgroundResource(android.R.color.holo_blue_dark);
    } else {//  w w  w  . j av  a  2  s  . co m
        view.setBackgroundResource(android.R.color.transparent);
    }

    TextView updateTextView = ((TextView) view.findViewById(android.R.id.text2));
    updateTextView.setVisibility(View.VISIBLE);

    if (cursor.isNull(errorPosition)) {
        long timestamp = cursor.getLong(lastUpdateColumn);

        // Date formatting is expensive, look at the cache
        String formattedDate = mFormattedDateCache.get(timestamp);
        if (formattedDate == null) {
            Date date = new Date(timestamp);

            formattedDate = context.getString(R.string.update) + COLON
                    + (timestamp == 0 ? context.getString(R.string.never)
                            : new StringBuilder(Constants.DATE_FORMAT.format(date)).append(' ')
                                    .append(Constants.TIME_FORMAT.format(date)));
            mFormattedDateCache.put(timestamp, formattedDate);
        }

        updateTextView.setText(formattedDate);
    } else {
        updateTextView.setText(new StringBuilder(context.getString(R.string.error)).append(COLON)
                .append(cursor.getString(errorPosition)));
    }

    byte[] iconBytes = cursor.getBlob(iconPosition);

    if (iconBytes != null && iconBytes.length > 0) {
        Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);

        if (bitmap != null && bitmap.getHeight() > 0 && bitmap.getWidth() > 0) {
            int bitmapSizeInDip = UiUtils.dpToPixel(18);

            if (bitmap.getHeight() != bitmapSizeInDip) {
                bitmap = Bitmap.createScaledBitmap(bitmap, bitmapSizeInDip, bitmapSizeInDip, false);
            }
            textView.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(context.getResources(), bitmap),
                    null, null, null);
        } else {
            textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        }
    } else {
        view.setTag(null);
        textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    }

    int unreadCount;
    synchronized (mUnreadItemsByFeed) {
        unreadCount = mUnreadItemsByFeed.get(feedId);
    }

    if (unreadCount > 0) {
        textView.setEnabled(true);
        updateTextView.setEnabled(true);
    } else {
        textView.setEnabled(false);
        updateTextView.setEnabled(false);
    }
    textView.setText(
            (cursor.isNull(namePosition) ? cursor.getString(linkPosition) : cursor.getString(namePosition))
                    + (unreadCount > 0 ? " (" + unreadCount + ")" : ""));

    View sortView = view.findViewById(R.id.sortitem);
    if (!sortViews.contains(sortView)) { // as we are reusing views, this is fine
        sortViews.add(sortView);
    }
    sortView.setVisibility(feedSort ? View.VISIBLE : View.GONE);
}

From source file:com.amaze.filemanager.fragments.ProcessViewer.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = (ViewGroup) inflater.inflate(R.layout.processparent, container, false);
    setRetainInstance(false);//  w  w  w . ja v a 2 s  .c o  m

    mainActivity = (MainActivity) getActivity();
    if (mainActivity.theme1 == 1)
        root.setBackgroundResource((R.color.cardView_background));
    rootView = (LinearLayout) root.findViewById(R.id.secondbut);
    //((MainActivity)getActivity()).getSupportActionBar().setTitle(utils.getString(getActivity(),R.string.processes));
    mainActivity.setActionBarTitle(utils.getString(getActivity(), R.string.processes));
    mainActivity.floatingActionButton.hideMenuButton(true);
    Sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    icons = new IconUtils(Sp, getActivity());
    mainActivity.supportInvalidateOptionsMenu();
    return root;
}

From source file:com.lichkin.customview.PagerSlidingTitleIconTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof LinearLayout) {
            if (((LinearLayout) v).getChildCount() > 1) {
                v = ((LinearLayout) v).getChildAt(1);
            } else {
                v = ((LinearLayout) v).getChildAt(0);
            }/*from   w w  w .j  av  a2s. co m*/
        }

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == currentPageSelected) {
                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.nadmm.airports.FragmentBase.java

protected void makeClickToCall(View row, int resid) {
    TextView tv = (TextView) row.findViewById(resid);
    makeClickToCall(tv);/*from w  ww.j av a  2 s .  co m*/
    if (tv.isClickable()) {
        row.setBackgroundResource(R.drawable.row_selector_middle);
    }
}

From source file:com.stx.xhb.dmgameapp.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(!tabSwitch ? tabBackgroundResId : transparentColorId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            TextPaint tp = tab.getPaint();
            tp.setFakeBoldText(false);/*  www.j  a  va 2s. com*/
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabSwitch && i != 0 ? tabDeactivateTextColor : 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));
                }
            }
        } else if (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;
            tab.setSelected(tabSwitch && i == 0 ? true : false);
        }
    }
}

From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java

/**
 * ?/*from   www. j a  v a2s  . com*/
 */
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));
                }
            }
            // 
            if (mSelectedPostion == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.trimph.toprand.trimphrxandroid.trimph.ui.main.news.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof RadioButton) {

            RadioButton tab = (RadioButton) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            //                tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //                tab.setTextColor(getContext().getResources().getColor(R.drawable.common_tab_strip_text_selector));
            //                tab.setTextColor(Color.parseColor("#303f9f"));

            if (i == currentPosition) {
                tab.setChecked(true);/*from   ww  w .  j  av  a  2s.  c  o  m*/
            } else {
                tab.setChecked(false);
            }

            // 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:org.rm3l.ddwrt.mgmt.RouterManagementActivity.java

/**
 * Called when an action mode is about to be exited and destroyed.
 *
 * @param actionMode The current ActionMode being destroyed
 *//* w w w. j  a v a  2s  .c o m*/
@Override
public void onDestroyActionMode(ActionMode actionMode) {
    this.actionMode = null;
    //Reset background for selected items
    for (int i = 0; i < this.dao.getAllRouters().size(); i++) {
        final View childAt;
        if ((childAt = mRecyclerView.getLayoutManager().getChildAt(i)) == null) {
            continue;
        }
        childAt.setBackgroundResource(android.R.color.transparent);
    }
    ((RouterListRecycleViewAdapter) mAdapter).clearSelections();
    addNewButton.setVisibility(View.VISIBLE);
}