@Override
protected Dialog onCreateDialog(int id) {
LayoutInflater factory = LayoutInflater.from(GmailFetchActivity.this);
final View textEntryView = factory.inflate(R.layout.alertdialog_gmail, null);
final EditText username = (EditText) textEntryView.findViewById(R.id.edit_username);
editxt_pass = (EditText) textEntryView.findViewById(R.id.edit_password);
final CheckBox remember = (CheckBox) textEntryView.findViewById(R.id.checkBox_remember);
username.setText(myPrefs.getString("username", ""));
editxt_pass.setText(myPrefs.getString("password", ""));
AlertDialog.Builder alert=new AlertDialog.Builder(this);
alert.setTitle("Gmail login");
alert.setView(textEntryView);
alert.setPositiveButton("Login", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if(username.getText().toString().trim().equalsIgnoreCase(""))
{
}
else{
if(isNetworkAvailable()){
String user=username.getText().toString();
String pass=editxt_pass.getText().toString();
if(remember.isChecked()){
prefsEditor.putString("username",user);
prefsEditor.putString("password",pass);
prefsEditor.commit();
}
else{
prefsEditor.putString("username","");
prefsEditor.putString("password","");
prefsEditor.commit();
}
progressHrz.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressHrz.setMessage("Fetching attachment's list");
progressHrz.setCancelable(true);
progressHrz.show();
new FetchGmail().execute(user+"@gmail.com",pass);
}
else
Toast.makeText(getApplicationContext(), "No internet access", Toast.LENGTH_LONG).show();
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
}
}) ;
return alert.create();
}
if the username is empty i just want to show a toast,but the dialog gets dismissedafter show the toast y?i want it to stay as it is