Java tutorial
//package com.java2s; import android.app.Activity; import android.widget.EditText; import android.widget.TextView; public class Main { /** * A method to get the string values from the res/strings.xml file. * * @param activity * @param resId * @return string */ public static String getStringFromId(final Activity activity, int resId) { if (activity == null) return ""; return activity.getString(resId); } /** * A method get the string from either the edit text or a text view. * * @param t * @return string */ public static String getString(Object t) { String s = ""; if (t instanceof EditText) { s = ((EditText) t).getText().toString(); } else { s = ((TextView) t).getText().toString(); } return s; } }