show popup message on button click without saving data to database
I am new to android and getting problems in showing popup message.
My problem is:
The popup message is coming fine when some required field is missed to
fill on the click of a save button but the field values are still getting
saved into the database.
They should only be saved if all the required fields are filled by the user.
My code logic is inside the save button onClick listener method in the
fragment.
Button save = (Button) view.findViewById(R.id.save);
save.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(isAlert)
{
Context context = getActivity().getApplicationContext();
Toast.makeText(context, "Please enter the required fields to proceed!",
Toast.LENGTH_LONG).show();
return;
}
createOrModifyTables(); //Database table save logic
//More then 1000 lines of code.....
}
I want to skip more then 1000 lines of code and the createOrModifyTables()
method after I return in the if condition. I can't just put
createOrModifyTables() inside the if condition.
No comments:
Post a Comment