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