Android examples for User Interface:EditText
Method to get a EditText with hint
import android.content.Context; import android.text.InputFilter; import android.widget.EditText; public class Main { /**/* ww w. ja v a2s . c o m*/ * Method to get a EditText with hint * * @param context * Context * @param hint * Hint to be displayed * @param maxLength * Max input allowed for the EditText * @return EditText */ public static EditText getEditTextWithHint(Context context, String hint, int maxLength) { final EditText mEditText = new EditText(context); mEditText.setHint(hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter( maxLength) }); return mEditText; } }