Example usage for android.widget TextView setPaintFlags

List of usage examples for android.widget TextView setPaintFlags

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setPaintFlags(int flags) 

Source Link

Document

Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.

Usage

From source file:Main.java

public static void setPaintFlags(TextView textView) {
    textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}

From source file:Main.java

/**
 * This method formats a TextView as if it was a hyperlink. This method
 * is useful when it's not a real HTML link but there's an OnClickListener
 * assigned to the TextView, taking you to some other action.
 *
 * @param t The TextView whose appearance is to be changed.
 *//*  w  w w  . jav  a 2s .  com*/
public static TextView renderAsLink(TextView t) {
    t.setPaintFlags(t.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    t.setTextColor(Color.BLUE);
    return t;
}

From source file:Main.java

/**
 * Remove strike through text view text flag.
 * @param textView//from  w  w  w  .  j a v a 2  s  .c om
 * @return
 */
public static TextView removeStrikeThroughTextView(TextView textView) {
    textView.setPaintFlags(textView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    return textView;
}

From source file:Main.java

public static void setStrikeThrough(TextView tv) {
    tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}

From source file:Main.java

/**
 * Set typeface for a TextView// w  w w.j  a v a2s  .  com
 *
 * @param typeFace
 * @param view
 */
public static void setTypeFace(Typeface typeFace, TextView view) {
    view.setTypeface(typeFace);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}

From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java

public static void setupLink(TextView textView, View.OnClickListener listener) {
    textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textView.setTextColor(App.getInstance().getResources().getColorStateList(R.color.about_link_dark));
    textView.setOnClickListener(listener);
}

From source file:com.xxxifan.devbox.core.util.ViewUtils.java

public static void addTextDelLine(TextView textView) {
    textView.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
}

From source file:eu.inmite.apps.smsjizdenka.framework.about.OpenSourceAdapter.java

private void openPlayServices(TextView textView) {
    textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textView.setOnClickListener(new View.OnClickListener() {

        @Override//from  w  w w. java  2 s . c o m
        public void onClick(View v) {
            PlayServicesLicenceDialogFragment.show(mFragmentManager);
        }
    });
}

From source file:com.juanvvc.fschecklistreader.ChecklistFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    // if the fragment is showing checklists, pass the event
    if (mode == MODE_CHECKLISTS) {
        if (this.listener != null) {
            this.listener.onChecklistClick(position);
        }/*from ww  w .  ja  va 2 s  .c  om*/
    }

    // the the fragment is showing items, strike the item
    if (mode == MODE_ITEMS) {
        TextView tv = (TextView) v.findViewById(R.id.name);
        tv.setPaintFlags(tv.getPaintFlags() ^ Paint.STRIKE_THRU_TEXT_FLAG);
        tv = (TextView) v.findViewById(R.id.value);
        tv.setPaintFlags(tv.getPaintFlags() ^ Paint.STRIKE_THRU_TEXT_FLAG);
    }
}

From source file:org.mozilla.focus.widget.TelemetrySwitchPreference.java

@Override
protected void onBindView(final View view) {
    super.onBindView(view);

    final Switch switchWidget = view.findViewById(R.id.switch_widget);

    switchWidget.setChecked(TelemetryWrapper.isTelemetryEnabled(getContext()));

    switchWidget.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/*from  w  w  w .  j a  va  2  s.c om*/
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            TelemetryWrapper.setTelemetryEnabled(getContext(), isChecked);
        }
    });

    final Resources resources = view.getResources();

    final TextView summary = view.findViewById(android.R.id.summary);
    summary.setText(resources.getString(R.string.preference_mozilla_telemetry_summary2,
            resources.getString(R.string.app_name)));

    final TextView learnMoreLink = view.findViewById(R.id.link);
    learnMoreLink.setPaintFlags(learnMoreLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    learnMoreLink.setTextColor(ContextCompat.getColor(view.getContext(), R.color.colorAction));
    learnMoreLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // This is a hardcoded link: if we ever end up needing more of these links, we should
            // move the link into an xml parameter, but there's no advantage to making it configurable now.
            final String url = SupportUtils.getSumoURLForTopic(getContext(), "usage-data");
            final String title = getTitle().toString();

            final Intent intent = InfoActivity.getIntentFor(getContext(), url, title);
            getContext().startActivity(intent);
        }
    });

    final TypedArray backgroundDrawableArray = view.getContext()
            .obtainStyledAttributes(new int[] { R.attr.selectableItemBackground });
    final Drawable backgroundDrawable = backgroundDrawableArray.getDrawable(0);
    backgroundDrawableArray.recycle();
    learnMoreLink.setBackground(backgroundDrawable);

    // We still want to allow toggling the pref by touching any part of the pref (except for
    // the "learn more" link)
    setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            switchWidget.toggle();
            return true;
        }
    });
}