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

public static void showMessage(ViewGroup emptyView, String msg) {
    if (emptyView == null) {
        return;//from   w w w. j  av  a  2 s  .co  m
    }
    ProgressBar pbLoading = (ProgressBar) emptyView.getChildAt(0);
    pbLoading.setVisibility(View.GONE);
    TextView tvEmptyMsg = (TextView) emptyView.getChildAt(1);
    tvEmptyMsg.setVisibility(View.VISIBLE);
    tvEmptyMsg.setText(msg);
}

From source file:Main.java

public static void setTextView(View view, int id, Object text) {
    if (view != null) {
        TextView tv = (TextView) view.findViewById(id);
        if (tv != null && text != null) {
            tv.setText(String.valueOf(text));
        }//w ww  .j a  va 2s  . c  om
    }
}

From source file:Main.java

public static void intentToAndroidLayoutMapper(Class<?> classObj, Intent intent, String prefixStr,
        Activity view) {/*from   ww  w .j  a v a 2 s . c  om*/

    Bundle map = intent.getExtras();

    for (Object keyObj : map.keySet().toArray()) {
        String keyStr = keyObj.toString();
        Field fieldObj = null;
        try {
            fieldObj = classObj.getField(prefixStr + "_" + keyStr);
        } catch (NoSuchFieldException e) {
            continue;
        }
        Object layoutObj = null;
        try {
            layoutObj = fieldObj.get(fieldObj);
        } catch (IllegalAccessException e) {
            continue;
        }
        Integer layoutIntvalue = (Integer) layoutObj;

        View selectedView = view.findViewById(layoutIntvalue);

        if (selectedView instanceof TextView) {
            TextView textView = (TextView) selectedView;
            textView.setText((String) map.get(keyStr));
        } else if (selectedView instanceof ImageView) {
            ImageView imageView = (ImageView) selectedView;

        }

    }

}

From source file:Main.java

public static void setTextView(Activity activity, int id, String text) {
    if (activity != null) {
        TextView tv = (TextView) activity.findViewById(id);
        if (tv != null && text != null) {
            tv.setText(String.valueOf(text));
        }// w  ww.jav  a 2s  .c o m
    }
}

From source file:Main.java

/**
 * Populate the given {@link TextView} with the requested text, formatting
 * through {@link Html#fromHtml(String)} when applicable. Also sets
 * {@link TextView#setMovementMethod} so inline links are handled.
 *///from  www  . j  av a 2  s.co m
public static void setTextMaybeHtml(TextView view, String text) {
    if (TextUtils.isEmpty(text)) {
        view.setText("");
        return;
    }
    if ((text.contains("<") && text.contains(">")) || REGEX_HTML_ESCAPE.matcher(text).find()) {
        view.setText(Html.fromHtml(text));
        view.setMovementMethod(LinkMovementMethod.getInstance());
    } else {
        view.setText(text);
    }
}

From source file:Main.java

static void updateTextView(Handler handler, final TextView tv, final String text) {
    handler.post(new Runnable() {
        public void run() {
            tv.setText(text);
        }//from   w w  w .  j a v  a2 s.  c  o m
    });
}

From source file:Main.java

public static void SetFlickerAnimation(final TextView v, final String info, final String temp) {
    v.setText(info);
    AlphaAnimation anim = new AlphaAnimation(0, 1);
    anim.setDuration(4000);//from  w  w w  . j  a v  a  2s  .c om
    anim.setRepeatCount(Animation.INFINITE);
    // anim1.setRepeatMode(Animation.REVERSE);
    anim.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation arg0) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
            // TODO Auto-generated method stub
            num++;
            if (num == 10) {
                num = 0;
            }
            if (num % 2 == 0) {
                v.setText(info);
            } else {
                v.setText(temp);
            }
        }

        @Override
        public void onAnimationEnd(Animation arg0) {
            // TODO Auto-generated method stub

        }
    });
    v.startAnimation(anim);

}

From source file:Main.java

public static boolean setText(View view, int id, String text) {
    TextView textView = (TextView) view.findViewById(id);
    if (textView == null)
        return false;

    textView.setText(text);
    return true;// w  w w  . j  av  a2 s .  c  o  m
}

From source file:Main.java

public static boolean setText(View view, int id, int text) {
    TextView textView = (TextView) view.findViewById(id);
    if (textView == null)
        return false;

    textView.setText(text);
    return true;/*from w  w w.  ja  v  a  2  s. c o  m*/
}

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

@BindingAdapter({ "android:classStr" })
public static void setClassStr(TextView view, String str) {
    view.setText(str);
}