Reputation: 1731
savebutton.setonclicklistenser:
if(edittext.getText().equals(""))
{
Toast.makeText(getBaseContext(),"enter data first",Toast.LENGTH_LONG);
}
else
{
//all the view insert data query stuff
//toast.maketext("data inserted");
}
but It shows result: "data inserted"
on click view button it shows all the empty slots which i added as string on tv.append("slot 1 "+slot1+"");
veiws all the slots like "slot1" string i passed in append method.
Upvotes: 0
Views: 59
Reputation: 3785
change if(edittext.gettext().equals(""))
condition to if(edittext.getText().toString().trim().equals(""))
add toString()
.
Upvotes: 3
Reputation: 936
Use Like This
if(edittext.getText().toString().equals(""))
{
Toast.makeText(getApplicationContext(),"enter data first",Toast.LENGTH_LONG).show();
}
else
{
//all the view insert data query stuff
//toast.maketext("data inserted");
}
Upvotes: 0
Reputation: 1193
You can write this
if(edittext.getText().toString().equals("")){
Toast.maketext(getApplicationcontext(),"enter data first",toast.length_long);
}
Instead of this
if(edittext.gettext().equals("")){
Toast.maketext(getbasecontext(),"enter data first",toast.length_long);
}
Upvotes: 0