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.facebook.notifications.internal.content.TextContent.java

@Override
public void applyTo(@NonNull View view) {
    if (view instanceof TextView) {
        TextView textView = (TextView) view;

        textView.setText(getText());/*from   w  w  w.j  a  va  2 s. c om*/
        textView.setTextColor(getTextColor());

        Typeface typeface = FontUtilities.parseFont(getTypeface());
        typeface = typeface != null ? typeface : Typeface.DEFAULT;

        textView.setTypeface(typeface);
        textView.setTextSize(getTypefaceSize());

        switch (getTextAlignment()) {
        case Left:
            textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
            break;

        case Center:
            textView.setGravity(Gravity.CENTER);
            break;

        case Right:
            textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            break;
        }
    }
}

From source file:de.vakuumverpackt.foul.About.java

@Override
public void onCreate(final Bundle bundle) {
    setContentView(R.layout.activity_about);

    TextView text = (TextView) findViewById(R.id.textView);
    text.setLinkTextColor(getLinkColor());
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text.setText(getText());//from  w  w w  .  j a  v a2  s  . co  m
    text.setTextColor(getTextColor());
}

From source file:com.test.shopping.view.ProductDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*/*from  www  .  j  a v  a  2s . co  m*/
     * Inflate the layout based on the current product details.
     * Fetch the product associated with the current position in product id list
     */
    ProductDataModel product = CacheUtil.getInstance(getActivity()).getProduct(mPosition);

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.product_detail, container, false);

    TextView productName = (TextView) rootView.findViewById(R.id.product_name);
    productName.setText(StringEscapeUtils.unescapeJava(product.getProductName()));

    String longDes = product.getLongDescription();
    TextView longDescLabel = (TextView) rootView.findViewById(R.id.long_description_label);
    TextView longDesc = (TextView) rootView.findViewById(R.id.long_description);
    if (longDes != null && longDes.length() > 0) {
        longDesc.setText(Jsoup.clean(longDes, Whitelist.simpleText()));
        longDesc.setVisibility(View.VISIBLE);
        longDescLabel.setVisibility(View.VISIBLE);
    } else {
        longDesc.setVisibility(View.INVISIBLE);
        longDescLabel.setVisibility(View.INVISIBLE);
    }

    TextView price = (TextView) rootView.findViewById(R.id.price);
    price.setText(product.getPrice());

    ImageView imageView = (ImageView) rootView.findViewById(R.id.image);
    ImageLoader loader = ConnectionUtil.getInstance(sContext).getImageLoader();
    loader.get(product.getProductImage(),
            ImageLoader.getImageListener(imageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher));

    TextView ratingCountView = (TextView) rootView.findViewById(R.id.rating_count);

    ratingCountView.setText("(" + String.valueOf(product.getReviewCount() + ")"));

    RatingBar bar = (RatingBar) rootView.findViewById(R.id.ratingBar);

    bar.setRating((int) product.getReviewRating());
    bar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    TextView inStock = (TextView) rootView.findViewById(R.id.inStock);
    if (product.isInStock()) {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_green_dark));
        inStock.setText(R.string.in_stock_label);
    } else {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
        inStock.setText(R.string.out_of_stock_label);
    }

    return rootView;
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java

@Override
public View getBody(final AppCompatActivity activity, final Integer textColor, final Float textSize,
        final boolean showLinkButtons) {

    final LinearLayout subjectLayout = new LinearLayout(activity);
    subjectLayout.setOrientation(LinearLayout.VERTICAL);

    final TextView subjectText = new TextView(activity);
    subjectText.setText(StringEscapeUtils.unescapeHtml4(src.subject != null ? src.subject : "(no subject)"));
    subjectText.setTextColor(textColor);
    subjectText.setTextSize(textSize);//w ww  .j  a v  a 2s . c om
    subjectText.setTypeface(null, Typeface.BOLD);

    subjectLayout.addView(subjectText);
    subjectLayout.addView(body.buildView(activity, textColor, textSize, showLinkButtons));

    return subjectLayout;
}

From source file:am.project.x.business.widgets.tagtabstrip.TagTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);
        views.add(text);//w  w  w  .j av  a  2 s. c o m
    }
    return views;
}

From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsDetail.java

void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    TextView textSSID = (TextView) view.findViewById(R.id.ssid);

    textSSID.setText(wiFiDetail.getTitle());

    view.findViewById(R.id.ipAddress).setVisibility(View.GONE);
    view.findViewById(R.id.linkSpeed).setVisibility(View.GONE);

    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    WiFiAdditional wiFiAdditional = wiFiDetail.getWiFiAdditional();
    if (wiFiAdditional.isConfiguredNetwork()) {
        configuredImage.setVisibility(View.VISIBLE);
        configuredImage.setColorFilter(resources.getColor(R.color.connected));
    } else {// ww w  . ja v  a  2  s  .  c  o  m
        configuredImage.setVisibility(View.GONE);
    }

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();
    ImageView imageView = (ImageView) view.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.imageResource());
    imageView.setColorFilter(resources.getColor(strength.colorResource()));

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(resources.getColor(R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(wiFiSignal.getLevel() + "dBm");
    textLevel.setTextColor(resources.getColor(strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());
    ((TextView) view.findViewById(R.id.primaryFrequency))
            .setText(wiFiSignal.getPrimaryFrequency() + WifiInfo.FREQUENCY_UNITS);
    ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance()));
    ((TextView) view.findViewById(R.id.channel_frequency_range))
            .setText(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd());
    ((TextView) view.findViewById(R.id.width))
            .setText("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WifiInfo.FREQUENCY_UNITS + ")");
    ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities());

    TextView textVendor = ((TextView) view.findViewById(R.id.vendor));
    String vendor = wiFiAdditional.getVendorName();
    if (StringUtils.isBlank(vendor)) {
        textVendor.setVisibility(View.GONE);
    } else {
        textVendor.setVisibility(View.VISIBLE);
        textVendor.setText(vendor.substring(0, Math.min(VENDOR_NAME_MAX, vendor.length())));
    }

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }

}

From source file:br.com.hojeti.wizardpager.ui.ReviewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_page, container, false);

    TextView titleView = (TextView) rootView.findViewById(android.R.id.title);
    titleView.setText(R.string.review);/* w w w  .j  a v  a2 s.c o m*/
    titleView.setTextColor(getResources().getColor(R.color.review_green));

    ListView listView = (ListView) rootView.findViewById(android.R.id.list);
    setListAdapter(mReviewAdapter);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    return rootView;
}

From source file:android.view.SpringIndicator.java

private void setSelectedTextColor(final int position) {
    for (final TextView tab : tabs)
        tab.setTextColor(getResources().getColor(textColorId));
    tabs.get(position).setTextColor(getResources().getColor(selectedTextColorId));
}

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

private void setSelectedTextColor(int position) {
    for (TextView tab : tabs) {
        tab.setTextColor(textColorId);
    }/*from www . j av a  2s. c  om*/
    tabs.get(position).setTextColor(getResources().getColor(selectedTextColorId));
}

From source file:com.chess.genesis.dialog.GameStatsDialog.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(title);/*from  ww w .j a v a  2s  .c om*/
    setBodyView(R.layout.dialog_endgame);
    setButtonTxt(R.id.cancel, "Close");

    final TextView score = (TextView) findViewById(R.id.psr_score);
    score.setText(psr_score);
    if (diff > 0)
        score.setTextColor(MColors.GREEN_DARK);
    else if (diff < 0)
        score.setTextColor(MColors.RED_DARK);

    // Set TextViews
    final int list[] = new int[] { R.id.opponent, R.id.result, R.id.psr_type };
    final String data[] = new String[] { opponent, result, psr_type };
    for (int i = 0; i < list.length; i++) {
        final TextView tv = (TextView) findViewById(list[i]);
        tv.setText(data[i]);
    }
}