Android TextView Set setHtml(Activity activity, View parent, int elementId, int resId)

Here you can find the source of setHtml(Activity activity, View parent, int elementId, int resId)

Description

set Html

Declaration

public static void setHtml(Activity activity, View parent,
            int elementId, int resId) 

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)));
    }// ww  w  . j a  va 2  s  .c  om

    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(TextView view, String html)
  4. initDate(TextView view,int days)
  5. setBold(TextView tv)
  6. manageVisibiltyFieldSpeech(Context context, ImageButton button, AutoCompleteTextView text, int idRightof, int idLeftOf, int idBelow)
  7. setupMarquee(TextView textView, String text)