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:cl.monsoon.s1next.binding.TextViewBindingAdapter.java

@BindingAdapter({ "forum", "gentleAccentColor" })
public static void setForum(TextView textView, Forum forum, int gentleAccentColor) {
    textView.setText(forum.getName());
    // add today's posts count to each forum
    if (forum.getTodayPosts() != 0) {
        ViewUtil.concatWithTwoSpacesForRtlSupport(textView, String.valueOf(forum.getTodayPosts()),
                gentleAccentColor);//from   w  w w.j a v  a2  s  .  c  om
    }
}

From source file:Main.java

public static void setTextViewEx(Map<String, Object> m, TextView v, String key, String format, String... en) {
    try {//w  w  w.ja  v  a 2s . c o  m
        int i = Integer.parseInt(toString(m.get(key)));
        String s = en[i];
        v.setText(String.format(format, s));
    } catch (Exception e) {
        v.setText("");
    }
}

From source file:Main.java

public static void setupTextView(TextView tv, CharSequence chars) {
    if (TextUtils.isEmpty(chars)) {
        tv.setVisibility(View.GONE);
    } else {//from ww w  . j  a  v  a 2  s .  c o m
        tv.setVisibility(View.VISIBLE);
        tv.setText(chars);
    }
}

From source file:Main.java

public static void updateTitle(TextView view, String title) {
    if (view != null && !TextUtils.isEmpty(title)) {
        view.setVisibility(View.VISIBLE);
        view.setSelected(true);//from   w  ww .  j  a  va  2s. co  m
        view.setText(title);
    }
}

From source file:Main.java

private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) {
    TextView textView = new TextView(activity);
    textView.setTextSize(textSize);/*  ww w .j a va 2s .c o m*/
    textView.setMaxWidth(maxWidth);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setText(text + "  ");
    layout.addView(textView);

}

From source file:android.databinding.testapp.adapter.MultiArgTestAdapter.java

@BindingAdapter({ "android:val3", "android:val4" })
public static void set2WithOldValues(TextView view, String oldValue1, String oldValue2, String newValue1,
        String newValue2) {/*  w w  w . ja  v  a2 s  .com*/
    view.setText(String.format("%s, %s -> %s, %s", oldValue1, oldValue2, newValue1, newValue2));
}

From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java

@BindingAdapter({ "themeManager", "thread", "user" })
public static void setThread(TextView textView, ThemeManager themeManager, Thread thread, User user) {
    textView.setText(thread.getTitle());
    if (thread.getPermission() != 0) {
        // add thread's permission hint
        ViewUtil.concatWithTwoSpacesForRtlSupport(textView,
                "[" + textView.getContext().getString(R.string.thread_permission_hint) + thread.getPermission()
                        + "]");
    }//w ww . j  av a2  s. c o m
    // disable TextView if user has no permission to access this thread
    boolean hasPermission = user.getPermission() >= thread.getPermission();
    textView.setEnabled(hasPermission);

    // add thread's replies count to each thread
    ViewUtil.concatWithTwoSpacesForRtlSupport(textView, String.valueOf(thread.getReplies()),
            hasPermission ? themeManager.getGentleAccentColor()
                    : themeManager.getHintOrDisabledGentleAccentColor());
}

From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java

@BindingAdapter("reply")
public static void setReply(TextView textView, @Nullable String reply) {
    if (TextUtils.isEmpty(reply)) {
        textView.setText(null);
    } else {//w  w w  .  j a  v  a 2  s  .  c o  m
        // use GlideImageGetter to show images in TextView
        textView.setText(
                Html.fromHtml(reply, new GlideImageGetter(textView.getContext(), textView), new TagHandler()));
    }
}

From source file:Main.java

public static void setText(TextView textView, boolean visible, String text) {
    if (textView != null) {
        if (visible && !TextUtils.isEmpty(text)) {
            textView.setVisibility(View.VISIBLE);
            textView.setText(text);
        } else {// www.  j  a  v a  2  s.  c o  m
            textView.setVisibility(View.GONE);
        }
    }
}

From source file:Main.java

public static void setText(Activity r, final TextView v, final String text) {
    r.runOnUiThread(new Runnable() {
        @Override/*  w ww. j  a v a2 s  .com*/
        public void run() {
            try {
                v.setSingleLine(false);
                v.setText(Html.fromHtml(text));
            } catch (Exception e) {
            }
        }
    });
}