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.agenmate.lollipop.addedit.AddEditFragment.java

private void formatText(TextView textView, String string) {
    if (string != null) {
        textView.setText(MarkupUtils.fromHtml(string));
    }/*  w  ww.ja  va 2s  . c o m*/
    textView.setTextColor(Color.BLACK);
    textView.setTypeface(FontUtils.get(getActivity(), "Dudu"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
}

From source file:android.view.SpringIndicator.java

private void addTabItems() {
    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
    tabs = new ArrayList<>();
    for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
        final TextView textView = new TextView(getContext());
        if (viewPager.getAdapter().getPageTitle(i) != null)
            textView.setText(viewPager.getAdapter().getPageTitle(i));
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(getResources().getColor(textColorId));
        if (textBgResId != 0)
            textView.setBackgroundResource(textBgResId);
        textView.setLayoutParams(layoutParams);
        final int position = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override/*from w  w w  . j a  va2s.com*/
            public void onClick(final View v) {
                if (tabClickListener == null || tabClickListener.onTabClick(position))
                    viewPager.setCurrentItem(position);
            }
        });
        tabs.add(textView);
        tabContainer.addView(textView);
    }
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public void setStatus(boolean success) {
    TextView status = (TextView) findViewById(R.id.operationForm_status);
    if (success) {
        status.setText(getString(R.string.operationForm_status_success));
        status.setTextColor(getResources().getColor(R.color.successGreen));
    } else {/* w w  w.j a va 2s  .c  o m*/
        status.setText(getString(R.string.operationForm_status_error));
        status.setTextColor(getResources().getColor(R.color.errorRed));
    }
}

From source file:android.support.common.view.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  a v  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);
    int color = getResources().getColor(R.color.color_clickable_gray_white);
    textView.setTextColor(color);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java

/**
 * ??tab./*from   w  w  w  .j  a v a 2 s . c o  m*/
 *
 * @param tabText the tab text
 * @param fragment the fragment
 */
public void addItemView(String tabText, Fragment fragment) {

    tabItemTextList.add(tabText);
    pagerItemList.add(fragment);

    tabItemList.clear();
    mTabLayout.removeAllViews();

    for (int i = 0; i < tabItemTextList.size(); i++) {
        final int index = i;
        String text = tabItemTextList.get(i);
        TextView tv = new TextView(this.context);
        tv.setTextColor(tabColor);
        tv.setTextSize(tabTextSize);
        tv.setText(text);
        tv.setGravity(Gravity.CENTER);
        tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1));
        tv.setPadding(12, 5, 12, 5);
        tv.setFocusable(false);
        tabItemList.add(tv);
        mTabLayout.addView(tv);
        tv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mViewPager.setCurrentItem(index);
            }
        });
    }

    //?
    AbLogUtil.d(AbSlidingSmoothTabView.class, "addItemView finish");
    mFragmentPagerAdapter.notifyDataSetChanged();
    mViewPager.setCurrentItem(0);
    computeTabImg(0);
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * ??tab.//  ww w. j a  v a  2 s.c  om
 *
 * @param tabText the tab text
 * @param fragment the fragment
 */
public void addItemView(String tabText, Fragment fragment) {

    tabItemTextList.add(tabText);
    pagerItemList.add(fragment);

    tabItemList.clear();
    mTabLayout.removeAllViews();

    for (int i = 0; i < tabItemTextList.size(); i++) {
        final int index = i;
        String text = tabItemTextList.get(i);
        TextView tv = new TextView(this.context);
        tv.setTextColor(tabColor);
        tv.setTextSize(tabTextSize);
        tv.setText(text);
        tv.setGravity(Gravity.CENTER);
        tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1));
        tv.setPadding(12, 5, 12, 5);
        tv.setFocusable(false);
        tabItemList.add(tv);
        mTabLayout.addView(tv);
        tv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mViewPager.setCurrentItem(index);
            }
        });
    }

    //?
    ESLogUtil.d(ESSlidingSmoothTabView.class, "addItemView finish");
    mFragmentPagerAdapter.notifyDataSetChanged();
    mViewPager.setCurrentItem(0);
    computeTabImg(0);
}

From source file:com.houseofslack.pullscoring.Scoring.java

private void changeInputFocus(int oldInputId, int newInputId) {
    TextView oldInput = (TextView) findViewById(oldInputId);
    TextView newInput = (TextView) findViewById(newInputId);
    newInput.setBackground(getResources().getDrawable(R.drawable.score_input_focused));
    newInput.setTextColor(getResources().getColor(R.color.focused_text_color));
    oldInput.setBackground(getResources().getDrawable(R.drawable.score_input_normal));
    oldInput.setTextColor(getResources().getColor(R.color.normal_text_color));
    mCurrentFocus = newInputId;//from w w  w.ja  va2s. co m
}

From source file:com.chenupt.springindicator.SpringIndicator.java

private void addTabItems() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
    tabs = new ArrayList<TextView>();
    for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
        TextView textView = new TextView(getContext());
        if (viewPager.getAdapter().getPageTitle(i) != null) {
            textView.setText(viewPager.getAdapter().getPageTitle(i));
        }// w ww . ja v  a2  s .  c  om
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(getResources().getColor(textColorId));
        if (textBgResId != 0) {
            textView.setBackgroundResource(textBgResId);
        }
        textView.setLayoutParams(layoutParams);
        final int position = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tabClickListener == null || tabClickListener.onTabClick(position)) {
                    viewPager.setCurrentItem(position);
                }
            }
        });
        tabs.add(textView);
        tabContainer.addView(textView);
    }
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java

private TextView getValueTextView(RelativeLayout widgetView, OpenHABWidget openHABWidget) {
    // Get TextView for widget value and set it's color
    Integer valueColor = openHABWidget.getValueColor();
    TextView valueTextView = (TextView) widgetView.findViewById(R.id.widgetvalue);

    if (valueColor != null && valueTextView != null) {
        Log.d(HABApplication.getLogTag(), String.format("Setting value color to %d", valueColor));
        valueTextView.setTextColor(valueColor);
    } else if (valueTextView != null) {
        TextView defaultTextView = new TextView(widgetView.getContext());
        valueTextView.setTextColor(defaultTextView.getTextColors().getDefaultColor());
    }//  w  ww .  j a v a  2s  .  c om

    return valueTextView;
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java

private TextView getLabelTextView(RelativeLayout widgetView, OpenHABWidget openHABWidget) {
    // Get TextView for widget label and set it's color
    Integer labelColor = openHABWidget.getLabelColor();
    TextView labelTextView = (TextView) widgetView.findViewById(R.id.widgetlabel);

    if (labelColor != null && labelTextView != null) {
        Log.d(HABApplication.getLogTag(), String.format("Setting label color to %d", labelColor));
        labelTextView.setTextColor(labelColor);
    } else if (labelTextView != null) {
        TextView defaultTextView = new TextView(widgetView.getContext());
        labelTextView.setTextColor(defaultTextView.getTextColors().getDefaultColor());
    }/* w ww  .  j a  v  a  2s. c  o m*/

    return labelTextView;
}