[Solved]How to detect where an editext is empty?

Put your problem here if it does not fit any of the other categories.

[Solved]How to detect where an editext is empty?

Postby cyberrob » Mon Feb 18, 2008 7:47 am

I Got two EditText which represent two value;
Code: Select all
EditText edit_filename = (EditText) findViewById(R.id.name);
EditText edit_filedcrp = (EditText) findViewById(R.id.description);

Then I wanna make sure that both EditText have been filled with some text inside,
So,
Code: Select all
if (edit_filename.getText().toString() != null
                  && edit_filename.getText().toString() != "") {
.....
}


It just can tell whether they're been filled or not! What shoule I do to get the edittext content?
Thx! :oops:
Last edited by cyberrob on Tue Feb 19, 2008 3:03 am, edited 1 time in total.
User avatar
cyberrob
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 13, 2007 3:01 am

Top

Postby res » Mon Feb 18, 2008 8:57 am

res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby plusminus » Mon Feb 18, 2008 9:39 am

Hello cyberrob,

just use:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String s = edit_filename.getText().toString()
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby cyberrob » Tue Feb 19, 2008 3:03 am

Thank U guys!
I found it has to be this way to find if the field is empty
Code: Select all
if(edit_filename.getText().toString().equals("")){
.....
}


So, IT solved! Thanks!! :D
User avatar
cyberrob
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Dec 13, 2007 3:01 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], MSNbot Media and 17 guests