submit button also validates and display an alert dialog
<p>In my application i am using a submit button which validates that all fields are inserted or not and then it shows an alert dialog that do u want to save or not.
Here is my code:</p>

<pre><code>public void OnClick_click2(final Button btnadd)
{
    final Button btn = (Button) btnadd;
    if(btn.getId()==R.id.btnadd){ 

    if(complain_date_txtbx.getText().toString().trim()
            .length() &lt; 1


                        SaveRecord(data);

                        Toast.makeText(getBaseContext(),
                                "Your Task saved Successfully!",
                                Toast.LENGTH_LONG).show();
                    }
                });

        alert.setNegativeButton("Cancel",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,
                            int whichButton) {
                        dialog.cancel();
                    }
                });

        alert.show();
        }
}
</code></pre>

<p>It doesn't show a/c to my my requirements, kindly identify where i go wrong and what is appropriate to first on clicking submit button it checks all fields and then display an alert dialog. Kindly guide me </p>
