List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:Main.java
public static void setValue(TextView v, String value) { String err_msg_which = ""; if (v != null) { if (TextUtils.isEmpty(value)) { err_msg_which = "Value"; value = ""; }//from w w w . ja va 2s. c o m v.setText(Html.fromHtml(value)); } else { err_msg_which = "TextView"; } }
From source file:Main.java
public static void buildLink(TextView view, String url) { Log.d(TAG, "buildLink(view = " + view + ", url = " + url + ")"); StringBuilder sb = new StringBuilder(); sb.append("<a href='").append(url).append("'>").append(view.getText()).append("</a>"); view.setText(Html.fromHtml(sb.toString())); view.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:Main.java
public static void setUnderLine(TextView tv) { if (tv.getText() != null) { String udata = tv.getText().toString(); SpannableString content = new SpannableString(udata); content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); tv.setText(content); content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); } else {// ww w.j ava 2s. c om tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); } }
From source file:Main.java
public static void setPartialColor(TextView tv, int start, int end, int textColor) { String s = tv.getText().toString(); Spannable spannable = new SpannableString(s); spannable.setSpan(new ForegroundColorSpan(textColor), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(spannable); }
From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java
@BindingAdapter("textPath") public static void loadTextAsset(TextView textView, String textPath) { try {//from w w w . ja va2 s. c o m InputStream inputStream = textView.getContext().getAssets().open(textPath); textView.setText(CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8))); } catch (IOException e) { throw new IllegalStateException("Can't find license.", e); } }
From source file:Main.java
protected static Bitmap creatCodeBitmap(String contents, int width, int height, Context context) { TextView tv = new TextView(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); tv.setLayoutParams(layoutParams);/*w ww . j a v a2s . co m*/ tv.setText(contents); tv.setHeight(height); tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setWidth(width); tv.setDrawingCacheEnabled(true); tv.setTextColor(Color.BLACK); tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.buildDrawingCache(); Bitmap bitmapCode = tv.getDrawingCache(); return bitmapCode; }
From source file:Main.java
public static void setValue(TextView v, String value, String defaultValue) { String err_msg_which = ""; if (v != null) { if (TextUtils.isEmpty(value)) { err_msg_which = "Value"; value = defaultValue;// w ww. j a v a 2 s .com } v.setText(Html.fromHtml(value)); } else { err_msg_which = "TextView"; } String err_msg_format = "%s is null"; // LogU.eLog(String.format(err_msg_format, err_msg_which)); }
From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java
@BindingAdapter({ "eventBus", "post" }) public static void setCount(TextView textView, EventBus eventBus, Post post) { String text = "#" + post.getCount(); // there is no need to quote #1 if ("1".equals(post.getCount())) { textView.setText(text); } else {//from w w w. ja va 2 s . c o m Spannable spannable = new SpannableString(text); URLSpan urlSpan = new URLSpan(StringUtils.EMPTY) { @Override public void onClick(@NonNull View widget) { eventBus.post(new QuoteEvent(post.getId(), post.getCount())); } }; spannable.setSpan(urlSpan, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannable); } }
From source file:Main.java
public static void animateTextViewTextChange(final TextView textView, final int duration, final String newText) { textView.animate().alpha(0f).setDuration(duration).setListener(new Animator.AnimatorListener() { @Override//from w w w . j a va2 s . co m public void onAnimationEnd(Animator animation) { textView.setText(newText); textView.animate().alpha(1f).setDuration(duration).start(); } @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }).start(); }
From source file:Main.java
private static void setText(TextView view, String text, boolean keepHtml) { CharSequence displayText = null; if (text != null) { displayText = keepHtml ? Html.fromHtml(text) : Html.fromHtml(text).toString(); }/*from ww w . j a v a 2s. co m*/ if (view != null) { if (displayText != null && !"".equals(displayText)) { view.setVisibility(View.VISIBLE); view.setText(displayText); } else { view.setVisibility(View.GONE); } } }