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:com.app.viaje.viaje.MapsActivity.java

/**
 * @description :://w  w  w.  j a  v a 2s  .co  m
 * Shows the AlertDialog that creates
 * a new post
 */
private void showMarkerPostDialog() {

    final EditText input = new EditText(MapsActivity.this);
    //Get the text from EditText.
    input.setInputType(InputType.TYPE_CLASS_TEXT);

    //Create AlertDialog Builder.
    AlertDialog.Builder builder = new AlertDialog.Builder(MapsActivity.this);
    builder.setTitle("Post");
    builder.setMessage("What about the post?");
    builder.setView(input);
    builder.setPositiveButton("Post", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            textContent = input.getText().toString().trim();

            if (textContent.isEmpty()) {
                Snackbar snackbar = Snackbar.make(relativeLayout, "Post must not be empty..",
                        Snackbar.LENGTH_LONG);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.RED);
                snackbar.show();
            } else {
                sendThePostToFirebase(textContent);
            }
        }
    });

    builder.create().show();
}

From source file:com.cssweb.android.quote.QuoteDetail.java

/**
 * /*from   w w  w .  j a v a  2s  .co m*/
 * @param jArr
 * @param table
 * @param zrsp
 * @throws JSONException
 */
private void appendRow(JSONArray jArr, TableLayout table, double zrsp) throws JSONException {
    table.setStretchAllColumns(true);
    table.removeAllViews();

    if ("cf".equals(exchange.toLowerCase()) || "dc".equals(exchange.toLowerCase())
            || "sf".equals(exchange.toLowerCase()) || "cz".equals(exchange.toLowerCase())) {
        int len = jArr.length();
        int color = Utils.getTextColor(mContext, 0);
        for (int i = 0; i < len; i++) {
            LinearLayout linearLayout = (LinearLayout) findViewById(R.id.title23);
            linearLayout.setVisibility(View.VISIBLE);

            JSONArray jA = (JSONArray) jArr.get(i);
            TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
            TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
            TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
            TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3);
            TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4);
            TextView t5 = (TextView) row.findViewById(R.id.zr_table_col5);
            t1.setText(jA.getString(4));
            t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
            t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
            t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            double cjsl = Arith.round(jA.getDouble(1), 0);
            t3.setText(Utils.dataFormation(cjsl, 0));
            t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            t4.setText(jA.getString(7));
            t5.setText(jA.getString(8));
            table.addView(row);
            if ("B".equals(jA.getString(6))) {
                color = Utils.getTextColor(mContext, 3);
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            } else if ("S".equals(jA.getString(6))) {
                color = Utils.getTextColor(mContext, 4);
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            } else {
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            }
        }
    } else {
        if (stocktype.charAt(0) == '0') {//
            //for (int i = jArr.length()-1; i >= 0; i--) {
            for (int i = 0; i <= jArr.length() - 1; i++) {
                JSONArray jA = (JSONArray) jArr.get(i);
                TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
                TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
                TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
                TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3);
                TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4);
                t1.setText(jA.getString(4));
                t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
                t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
                t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
                double cjsl = Arith.round(jA.getDouble(1), 0);
                t3.setText(Utils.dataFormation(cjsl, 0));
                if (cjsl > 500)
                    t3.setTextColor(Utils.getTextColor(mContext, 6));
                else
                    t3.setTextColor(Utils.getTextColor(mContext, 1));
                t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
                t4.setText(jA.getString(6));
                if ("B".equals(jA.getString(6)))
                    t4.setTextColor(Utils.getTextColor(mContext, 3));
                else
                    t4.setTextColor(Utils.getTextColor(mContext, 4));
                table.addView(row);
            }
            //?
            int num = jArr.length();
            if (num < 16) {
                while (num < 16) {
                    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item,
                            null);
                    table.addView(row);
                    num++;
                }
            }
        } else if (stocktype.charAt(0) == '1' || stocktype.charAt(0) == '2') {//
            //for (int i = jArr.length()-1; i >= 0; i--) {
            for (int i = 0; i <= jArr.length() - 1; i++) {
                JSONArray jA = (JSONArray) jArr.get(i);
                TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
                TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
                TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
                TextView t3 = (TextView) row.findViewById(R.id.zr_table_col4);
                t1.setText(jA.getString(4));
                t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
                t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
                t3.setText(Utils.getAmountFormat(jA.getDouble(5), true));
                t3.setTextColor(Utils.getTextColor(mContext, 1));
                table.addView(row);
            }
            //?
            int num = jArr.length();
            if (num < 16) {
                while (num < 16) {
                    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item,
                            null);
                    table.addView(row);
                    num++;
                }
            }
        }
    }

}

From source file:com.advaitaworld.widgets.SlidingTabLayout.java

private void updateTitleColors(int prevSelectedPosition, int newSelectedPosition) {
    if (mSelectedTabColor == 0 && mDefaultTabColor == 0) {
        return;/*from  w w w  . ja  v  a 2s  . c  o m*/
    }
    View tabViewPrev = mTabStrip.getChildAt(prevSelectedPosition);
    View tabViewNew = mTabStrip.getChildAt(newSelectedPosition);
    final TextView tabTitlePrev = getTabTitleView(tabViewPrev);
    final TextView tabTitleNew = getTabTitleView(tabViewNew);

    ArgbEvaluator evaluator = new ArgbEvaluator();
    ValueAnimator anim1 = new ValueAnimator();
    anim1.setIntValues(mDefaultTabColor, mSelectedTabColor);
    anim1.setEvaluator(evaluator);
    anim1.setDuration(300);
    anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitleNew.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    ValueAnimator anim2 = new ValueAnimator();
    anim2.setIntValues(mSelectedTabColor, mDefaultTabColor);
    anim2.setEvaluator(evaluator);
    anim2.setDuration(300);
    anim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            tabTitlePrev.setTextColor((Integer) valueAnimator.getAnimatedValue());
        }
    });

    anim1.start();
    anim2.start();
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

protected void refreshTable(List<String[]> list, int scrollNum, String exchange) throws JSONException {
    double d0 = 0;
    clearData(scrollNum);/*from   w  w w . j a  va 2 s.  co  m*/

    if (null != list) {
        initQuote();

        for (int i = 1; i <= list.size(); i++) {
            try {
                String[] cs = list.get(i - 1);
                d0 = Double.parseDouble(cs[cs.length - 1]);
                // ??
                int digit = Utils.getStockDigit(NameRule.getSecurityType(exchange, cs[cs.length - 3]));

                LinearLayout localLinearLayout = (LinearLayout) this.mLinerHScroll.findViewWithTag(i);
                int i6 = localLinearLayout.getChildCount();
                for (int j = 0; j < i6; j++) {
                    TextView localView6 = (TextView) localLinearLayout.getChildAt(j);
                    // Log.i("tag", "cs[j]"+cs[j]);
                    double zf = Double.parseDouble(cs[j]);

                    if (j == 0) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 2) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 1) {// 
                        String str1;
                        if (zf == 0)
                            str1 = Utils.dataFormation(zf * 100, 1);
                        else
                            str1 = Utils.dataFormation(zf * 100, 1);
                        localView6.setTextColor(Utils.getTextColor(mContext, zf));
                        localView6.setText(str1);

                    } else if (j == 3 || j == 4) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 5 || j == 6) {// ???
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 7) {// ?
                        localView6.setTextColor(
                                Utils.getTextColor(mContext, Utils.getColorFromBS(cs[cs.length - 4])));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 8) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 9 || j == 10 || j == 11) {// ,
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 17) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, 0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 12) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 13) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 14 || j == 15) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 16) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 2));
                        localView6.setText(Utils.getAmountFormat(zf, false, 2));
                    }

                    // ???t? 1
                    // ?t? 0
                    // //?, ? d0
                    // , 0
                    // Utils.getAmountFormat(zf, false)
                    // Utils.dataFormation(zf, mDigit)

                    // Utils.getTextColor(mContext, zf, d0) 
                    // Utils.getTextColor(mContext, zf) 0
                    // Utils.getTextColor(mContext, 1) ?t?

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:cn.com.pplo.sicauhelper.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
            if (i == 0) {
                tab.setTextColor(Color.parseColor("#ffffff"));
            } else {
                tab.setTextColor(tabTextColor);
            }/*from w  w  w  .  j a va  2  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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.benefit.buy.library.viewpagerindicator.PagerSlidingTabStrip.java

@SuppressLint("NewApi")
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 va2 s .c o m
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        } else {
            View vImg = v.findViewById(R.id.img_click);
            View vText = v.findViewById(R.id.tab_name);
            if (vText instanceof TextView) {
                TextView tab = (TextView) vText;
                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 (vImg instanceof ImageView) {
                ImageView img = (ImageView) vImg;
                if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
                    if ((i == selectedPosition) || (i == (selectedPosition + 1))
                            || (i == (selectedPosition - 1))) {
                        //                    tab.setTextColor(selectedTabTextColor);
                        img.setAlpha(0f);
                        img.setVisibility(View.VISIBLE);
                    } else {
                        img.setVisibility(View.INVISIBLE);
                    }
                } else {
                    if ((i == selectedPosition)) {
                        //                    tab.setTextColor(selectedTabTextColor);
                        img.setVisibility(View.VISIBLE);
                    } else {
                        img.setVisibility(View.INVISIBLE);
                    }
                }
            }
        }
    }
}

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 {/*from   w  ww  . j  a  va2  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.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

private void setChooseTabViewTextColor(int position) {
    int childCount = tabsContainer.getChildCount();
    LinearLayout tabView;/*from   w w  w .j  a v  a  2s  .c o m*/
    TextView textView;
    for (int i = 0; i < childCount; ++i) {
        tabView = (LinearLayout) tabsContainer.getChildAt(i);
        textView = (TextView) tabView.findViewById(R.id.tab_title_label);
        if (i == position) {
            textView.setTextColor(getResources().getColor(checkedTextColor));
        } else {
            textView.setTextColor(getResources().getColor(unCheckedTextColor));
        }
    }
}

From source file:com.astuetz.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  ww  .  j  a va2 s  .  c  o 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.amaze.filemanager.fragments.ProcessViewer.java

void processCompressResults(DataPackage dataPackage) {
    final int id = dataPackage.getId();

    if (!CancelledZipIds.contains(id)) {
        if (ZipIds.contains(id)) {
            boolean completed = dataPackage.isCompleted();
            View process = rootView.findViewWithTag("zip" + id);
            if (completed) {
                rootView.removeViewInLayout(process);
                ZipIds.remove(ZipIds.indexOf(id));
            } else {
                String name = dataPackage.getName();
                int p1 = dataPackage.getP1();

                ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1);
                if (p1 <= 100) {
                    ((TextView) process.findViewById(R.id.progressText)).setText(
                            utils.getString(getActivity(), R.string.zipping) + "\n" + name + "\n" + p1 + "%");

                    p.setProgress(p1);//from   w  ww.  java 2 s. co  m
                }
            }
        } else {
            CardView root = (CardView) getActivity().getLayoutInflater().inflate(R.layout.processrow, null);
            root.setTag("zip" + id);

            ImageView progressImage = ((ImageView) root.findViewById(R.id.progressImage));
            ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button);
            TextView progressText = (TextView) root.findViewById(R.id.progressText);

            if (mainActivity.theme1 == 1) {

                root.setCardBackgroundColor(R.color.cardView_foreground);
                root.setCardElevation(0f);
                cancel.setImageResource(R.drawable.ic_action_cancel);
                progressText.setTextColor(Color.WHITE);
                progressImage.setImageResource(R.drawable.ic_doc_compressed);
            } else {

                // cancel has default src set for light theme
                progressText.setTextColor(Color.BLACK);
                progressImage.setImageResource(R.drawable.ic_doc_compressed_black);
            }

            cancel.setOnClickListener(new View.OnClickListener() {

                public void onClick(View p1) {
                    Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping),
                            Toast.LENGTH_LONG).show();
                    Intent i = new Intent("zipcancel");
                    i.putExtra("id", id);
                    getActivity().sendBroadcast(i);
                    rootView.removeView(rootView.findViewWithTag("zip" + id));

                    ZipIds.remove(ZipIds.indexOf(id));
                    CancelledZipIds.add(id);
                    // TODO: Implement this method
                }
            });

            String name = dataPackage.getName();
            int p1 = dataPackage.getP1();

            ((TextView) root.findViewById(R.id.progressText))
                    .setText(utils.getString(getActivity(), R.string.zipping) + "\n" + name);
            ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1);
            p.setProgress(p1);

            ZipIds.add(id);
            rootView.addView(root);
        }
    }
}