Example usage for android.widget TextView setTextColor

List of usage examples for android.widget TextView setTextColor

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setTextColor(ColorStateList colors) 

Source Link

Document

Sets the text color.

Usage

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *//*from w w  w  .  j a va2s . co  m*/
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            PaintDrawable background = new PaintDrawable(Color.GRAY);
            background.setCornerRadius(5);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i] + " | X");
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(5, 2, 5, 2);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java

private void populateUpcomingDates() {
    long startTime = System.currentTimeMillis();
    TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates);
    dateListTable.removeAllViews();/*  www.j  a  v  a 2  s.c  o  m*/

    if (mDashboardModel.getDates().isEmpty()) {
        getView().findViewById(R.id.dates_empty).setVisibility(View.VISIBLE);
        return;
    } else {
        getView().findViewById(R.id.dates_empty).setVisibility(View.GONE);
    }

    Termin previousDate = null;
    for (Termin date : mDashboardModel.getDates()) {
        Date from = date.getDatum();

        View dateTableRow = getActivity().getLayoutInflater().inflate(R.layout.dashboard_date, dateListTable,
                false);
        TextView dateText = (TextView) dateTableRow.findViewById(R.id.text_date);
        TextView timeText = (TextView) dateTableRow.findViewById(R.id.text_time);
        TextView roomText = (TextView) dateTableRow.findViewById(R.id.text_room);
        TextView titleText = (TextView) dateTableRow.findViewById(R.id.text_title);

        dateText.setText(getString(R.string.calendar_date, from));
        timeText.setText(getString(R.string.calendar_time, from));
        roomText.setText(date.getRaum());
        titleText.setText(date.getTitleWithType());

        int color = 0;
        if (date.isStorniert()) {
            color = getResources().getColor(R.color.date_canceled);
        } else if (date.isNow()) {
            color = getResources().getColor(R.color.date_running);
        }
        if (color != 0) {
            dateText.setTextColor(color);
            timeText.setTextColor(color);
            roomText.setTextColor(color);
            titleText.setTextColor(color);
        }

        if (previousDate != null && Utils.isSameDay(previousDate.getDatum(), date.getDatum())) {
            dateText.setVisibility(View.INVISIBLE);
        }

        dateTableRow.setVisibility(View.INVISIBLE); // will be unhidden by #adjustDateListHeight()
        dateListTable.addView(dateTableRow);
        previousDate = date;
    }
    long deltaTime = System.currentTimeMillis() - startTime;
    Log.d(TAG, "populateUpcomingDates: " + deltaTime + "ms");
    adjustDateListHeight();
}

From source file:ca.qc.johnabbott.cs603.ExternalLibraries.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 w w  . j  av 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);
    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);
    textView.setTextColor(context.getResources().getColor(R.color.colorSecondary));

    return textView;
}

From source file:app.learning.fantaster.nhatkyhoctiengnhat.util.slidingtab.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;//w  w  w. j ava2 s. c  o  m
        TextView tabTitleView = null;

        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);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

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

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

        CharSequence title = adapter.getPageTitle(i);
        tabTitleView.setText(title);
        tabTitleView.setGravity(Gravity.CENTER_HORIZONTAL);
        tabTitleView.setTextColor(Color.WHITE);
        tabView.setOnClickListener(tabClickListener);

        if (mDistributeEvenly) {
            tabView.setLayoutParams(layoutParams);
        }

        mTabStrip.addView(tabView);
    }
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

/**
 * Create or recreate the limiter breadcrumbs.
 *//*from w  ww  . j  a  v  a  2s.c om*/
public void updateLimiterViews() {
    mLimiterViews.removeAllViews();

    Limiter limiterData = mPagerAdapter.getCurrentLimiter();
    if (limiterData != null) {
        String[] limiter = limiterData.names;

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        for (int i = 0; i != limiter.length; ++i) {
            int color = (i + 1 == limiter.length ? 0xFFA0A0A0 : 0xFFC0C0C0);
            PaintDrawable background = new PaintDrawable(color);
            background.setCornerRadius(0);

            TextView view = new TextView(this);
            view.setSingleLine();
            view.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            view.setText(limiter[i]);
            view.setTextColor(Color.WHITE);
            view.setBackgroundDrawable(background);
            view.setLayoutParams(params);
            view.setPadding(14, 6, 14, 6);
            view.setTag(i);
            view.setOnClickListener(this);
            mLimiterViews.addView(view);
        }

        mLimiterScroller.setVisibility(View.VISIBLE);
    } else {
        mLimiterScroller.setVisibility(View.GONE);
    }
}

From source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }//w  ww.  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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.cssweb.android.base.DialogActivity.java

protected void initStockBar() {
    hiddenOrDisplayStockBar(View.VISIBLE);

    TextView stkBar1 = (TextView) findViewById(R.id.njzq_userstockbtn1);
    TextView stkBar2 = (TextView) findViewById(R.id.njzq_userstockbtn2);
    TextView stkBar3 = (TextView) findViewById(R.id.njzq_userstockbtn3);
    TextView stkBar4 = (TextView) findViewById(R.id.njzq_userstockbtn4);
    TextView stkBar5 = (TextView) findViewById(R.id.njzq_userstockbtn5);
    TextView stkBar6 = (TextView) findViewById(R.id.njzq_userstockbtn6);

    stkBar1.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar1.setOnClickListener(toolbarClick);
    stkBar1.setVisibility(View.VISIBLE);
    stkBar1.setTag(11);//from  w w w.  j a v  a  2  s.co  m

    stkBar2.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar2.setOnClickListener(toolbarClick);
    stkBar2.setVisibility(View.VISIBLE);
    stkBar2.setTag(12);

    stkBar3.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar3.setOnClickListener(toolbarClick);
    stkBar3.setVisibility(View.VISIBLE);
    stkBar3.setTag(13);

    stkBar4.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar4.setOnClickListener(toolbarClick);
    stkBar4.setVisibility(View.VISIBLE);
    stkBar4.setTag(14);

    stkBar5.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar5.setOnClickListener(toolbarClick);
    stkBar5.setVisibility(View.VISIBLE);
    stkBar5.setTag(15);

    stkBar6.setTextColor(getResources().getColor(R.color.zr_white));
    stkBar6.setOnClickListener(toolbarClick);
    stkBar6.setVisibility(View.VISIBLE);
    stkBar6.setTag(16);
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Populate the koopman fragment item details item when the loader has finished
 * @param loader the cursor loader/*from w w  w.  j ava2 s  .  co  m*/
 * @param data data object containing one or more koopman rows with joined sollicitatie data
 */
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        boolean validSollicitatie = false;

        // get the markt id from the sharedprefs
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0);

        // make the koopman details visible
        mKoopmanDetail.setVisibility(View.VISIBLE);

        // check koopman status
        String koopmanStatus = data.getString(data.getColumnIndex("koopman_status"));
        mMeldingVerwijderd = koopmanStatus.equals(getString(R.string.koopman_status_verwijderd));

        // koopman photo
        Glide.with(getContext())
                .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL)))
                .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage);

        // koopman naam
        String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " "
                + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM));
        mKoopmanVoorlettersAchternaamText.setText(naam);

        // koopman erkenningsnummer
        mErkenningsnummer = data
                .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER));
        mErkenningsnummerText.setText(mErkenningsnummer);

        // koopman sollicitaties
        View view = getView();
        if (view != null) {
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder);
            placeholderLayout.removeAllViews();

            // get vaste producten for selected markt, and add multiple markt sollicitatie views to the koopman items
            while (!data.isAfterLast()) {

                // get vaste producten for selected markt
                if (marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    String[] productParams = getResources().getStringArray(R.array.array_product_param);
                    for (String product : productParams) {
                        mProducten.put(product, data.getInt(data.getColumnIndex(product)));
                    }
                }

                // inflate sollicitatie layout and populate its view items
                View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie,
                        null);

                // highlight the sollicitatie for the current markt
                if (data.getCount() > 1 && marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
                }

                // markt afkorting
                String marktAfkorting = data
                        .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING));
                TextView marktAfkortingText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_markt_afkorting);
                marktAfkortingText.setText(marktAfkorting);

                // koopman sollicitatienummer
                String sollicitatienummer = data.getString(
                        data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER));
                TextView sollicitatienummerText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_sollicitatie_nummer);
                sollicitatienummerText.setText(sollicitatienummer);

                // koopman sollicitatie status
                String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status"));
                TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status);
                sollicitatieStatusText.setText(sollicitatieStatus);
                if (sollicitatieStatus != null && !sollicitatieStatus.equals("?")
                        && !sollicitatieStatus.equals("")) {
                    sollicitatieStatusText
                            .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
                    sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(),
                            Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus)));

                    // check if koopman has at least one valid sollicitatie on selected markt
                    if (marktId == data
                            .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                        validSollicitatie = true;
                    }
                }

                // add view and move cursor to next
                placeholderLayout.addView(childLayout, data.getPosition());
                data.moveToNext();
            }
        }

        // check valid sollicitatie
        mMeldingNoValidSollicitatie = !validSollicitatie;

        // get the date of today for the dag param
        SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_dag));
        String dag = sdf.format(new Date());

        // check multiple dagvergunningen
        Cursor dagvergunningen = getContext().getContentResolver().query(
                MakkelijkeMarktProvider.mUriDagvergunningJoined, null,
                "dagvergunning_doorgehaald != '1' AND " + MakkelijkeMarktProvider.mTableDagvergunning + "."
                        + MakkelijkeMarktProvider.Dagvergunning.COL_MARKT_ID + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_DAG + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE + " = ? ",
                new String[] { String.valueOf(marktId), dag, mErkenningsnummer, }, null);
        mMeldingMultipleDagvergunningen = (dagvergunningen != null && dagvergunningen.moveToFirst())
                && (dagvergunningen.getCount() > 1 || mDagvergunningId == -1);
        if (dagvergunningen != null) {
            dagvergunningen.close();
        }

        // callback to dagvergunning activity to updaten the meldingen view
        ((Callback) getActivity()).onMeldingenUpdated();
    }
}

From source file:base.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        //            v.setBackgroundResource(tabBackgroundResId);
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }//from ww w . j  a  v  a2 s .c  om
            // 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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.box.myview.MyTopSnackBar.TSnackbar.java

/**
 * Sets the text color of the action specified in
 * {@link #setAction(CharSequence, View.OnClickListener)}.
 *///from ww  w.ja v  a2 s.co  m
@NonNull
public TSnackbar setMessageTextColor(@ColorInt int color) {
    final TextView tv = mView.getMessageView();
    tv.setTextColor(color);
    return this;
}