Java tutorial
//package com.java2s; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class Main { public static void setText(View view, String val) { if (val == null || val.trim().length() < 1) return; if (view instanceof TextView) { ((TextView) view).setText(val); } else if (view instanceof EditText) { ((EditText) view).setText(val); } } }