Android TextView Set setHtml(TextView view, String html)

Here you can find the source of setHtml(TextView view, String html)

Description

set Html

Declaration

public static void setHtml(TextView view, String html) 

Method Source Code

//package com.java2s;
import android.app.Activity;

import android.text.Html;

import android.view.View;
import android.widget.TextView;

public class Main {
    public static void setHtml(Activity activity, View parent,
            int elementId, int resId) {
        TextView view = (TextView) parent.findViewById(elementId);
        view.setText(Html.fromHtml(activity.getString(resId)));
    }//from w w  w.j a  v  a 2 s  .com

    public static void setHtml(TextView view, String html) {
        view.setVisibility(View.GONE);

        if (html != null && html.length() != 0) {
            view.setText(Html.fromHtml(html));
            view.setVisibility(View.VISIBLE);
        }
    }

    public static void setText(TextView view, String text) {
        if (isEmpty(text)) {
            view.setVisibility(View.GONE);
            return;
        }

        view.setText(text);
        view.setVisibility(View.VISIBLE);
    }

    public static boolean isEmpty(String s) {
        return (s == null || s.length() == 0);
    }

    public static boolean isEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }
}

Related

  1. setText(TextView tv, String str)
  2. setText(TextView tv, int str)
  3. setHtml(Activity activity, View parent, int elementId, int resId)
  4. initDate(TextView view,int days)
  5. setBold(TextView tv)
  6. manageVisibiltyFieldSpeech(Context context, ImageButton button, AutoCompleteTextView text, int idRightof, int idLeftOf, int idBelow)