Dave's Brain

Browse - Programming Tips - How do I get the text from an EditText widget?

Date: 2015jul30
OS: Android
Language: Java

Q.  How do I get the text from an EditText widget?

A.	You need to do toString() on the return of getText() like this:

EditText editText = (EditText) findViewById(R.id.my_edittext); String s = editText.getText().toString().trim();
Doesn't hurt to throw in a trim() too.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.