Java tutorial
//package com.java2s; //License from project: Open Source License import android.text.Html; import android.view.View; import android.widget.TextView; public class Main { 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(); } if (view != null) { if (displayText != null && !"".equals(displayText)) { view.setVisibility(View.VISIBLE); view.setText(displayText); } else { view.setVisibility(View.GONE); } } } }