Example usage for android.widget TextView setText

List of usage examples for android.widget TextView setText

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setText(@StringRes int resid) 

Source Link

Document

Sets the text to be displayed using a string resource identifier.

Usage

From source file:Main.java

private static void viewSetText(View textView, SpannableString mSpannableString) {
    if (textView instanceof TextView) {
        TextView tv = (TextView) textView;
        tv.setText(mSpannableString);
    } else if (textView instanceof EditText) {
        EditText et = (EditText) textView;
        et.setText(mSpannableString);//from   ww w.ja va  2 s  .  c o m
    }
}

From source file:Main.java

public static void applyTextEmoticon(Context context, TextView view) {
    view.setText(getEmoticonText(context, view.getText()));
}

From source file:Main.java

public static void formatPadWithZero(TextView txt, int number) {
    if (number < 10) {
        txt.setText("0" + number);
    } else {//  w  ww . j  a  va2s  . com
        txt.setText("" + number);
    }

}

From source file:Main.java

public static void formatPadWithBlank(TextView txt, int number) {
    if (number < 10) {
        txt.setText(" " + number);
    } else {/*  w w w  . jav a 2s .c o  m*/
        txt.setText("" + number);
    }

}

From source file:Main.java

private static void setPrice(TextView text, Double amount) {
    int i = amount.intValue();
    text.setText("$" + i);
}

From source file:Main.java

public static TextView setText(View parent, int textViewId, CharSequence text) {
    TextView textView = (TextView) parent.findViewById(textViewId);
    textView.setText(text);
    return textView;
}

From source file:Main.java

public static void formatHtmlString(String string, TextView textView) {

    textView.setText(Html.fromHtml(string));
    Linkify.addLinks(textView, Pattern.compile(FILICK_URL_EXPRESSION), "http://", new MatchFilter() { //$NON-NLS-1$

        @Override/*w w w . j ava  2 s  .c o  m*/
        public boolean acceptMatch(CharSequence s, int start, int end) {
            return true;
        }

    }, new TransformFilter() {

        @Override
        public String transformUrl(Matcher matcher, String data) {
            if (data.length() > 2) {
                return data.substring(1, data.length() - 1);
            }
            return data;
        }

    });
}

From source file:Main.java

public static void populateTextView(int textViewId, String value, Activity activity) {
    TextView textView = (TextView) activity.findViewById(textViewId);

    textView.setText(value);
}

From source file:Main.java

private static void makeHtml(ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        final View childView = viewGroup.getChildAt(i);
        if (childView instanceof TextView) {
            final TextView curr = (TextView) childView;
            curr.setText(Html.fromHtml(curr.getText().toString()));
        }//  w  w  w . j av  a  2s . c o m

        if (childView instanceof ViewGroup) {
            makeHtml((ViewGroup) childView);
        }
    }
}

From source file:Main.java

public static void setDate(TextView dateView, Typeface font) {
    dateView.setTypeface(font);/*from   w  ww.  j av  a  2s. c o  m*/
    dateView.setText(new SimpleDateFormat("EEEE, MMMM d yyyy").format(new Date()));
}