Java tutorial
//package com.java2s; import android.app.Activity; import android.view.View; import android.widget.TextView; public class Main { public static void setTextView(View view, int id, Object text) { if (view != null) { TextView tv = (TextView) view.findViewById(id); if (tv != null && text != null) { tv.setText(String.valueOf(text)); } } } public static void setTextView(Activity activity, int id, String text) { if (activity != null) { TextView tv = (TextView) activity.findViewById(id); if (tv != null && text != null) { tv.setText(String.valueOf(text)); } } } }