Java tutorial
//package com.java2s; import android.text.TextUtils; import android.view.View; import android.widget.TextView; public class Main { public static boolean setText(TextView textView, String string) { if (textView == null) return false; textView.setText(TextUtils.isEmpty(string) ? "" : string); return true; } public static void setText(View group, int id, String string) { if (group == null) return; View view = group.findViewById(id); if (view != null && view instanceof TextView) { setText((TextView) view, string); } } }