Android examples for User Interface:EditText
get EditText As Value Trim To Null
//package com.book2s; import android.widget.EditText; public class Main { public static String getEditTextAsValueTrimToNull(EditText view) { String nameDirty = view.getText().toString(); return trimToNull(nameDirty); }//from w w w.j av a 2 s.c o m public static String trimToNull(String nameDirty) { String name = nameDirty; if (name != null) { name = name.trim(); if (name.length() < 1) { name = null; } } return name; } }