Following is the code I have created for 2 dialog boxes: namely Date Picker and Custom Dialog Box on submit of 2 buttons namely btnselDate and btnAlertDialog.
Date Picker dialog is working properly but there is some problem with Custom Dialog Box. My custom dialogbox displays login form for the user.
Kindly please review it and suggest appropriate suggestions for the same.
Here goes the code:
public void onClick(View view)
{
if(view.getId() == R.id.btnselDate)
{
// Date Picket DialogBox
showDialog(1);
}
else if(view.getId()==R.id.btnAlertDialog)
{
// Alert Dialog Box
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_activity);
dialog.setTitle("Custom Dialog");
TextView text = (TextView) dialog.findViewById(R.id.tvPwd);
text.setText("Enter the Password");
final EditText pwd=(EditText) dialog.findViewById(R.id.etPwd);
Button btnlogin=(Button) dialog.findViewById(R.id.btnOK);
btnlogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//Login Button
if(pwd.getText().toString().equals("abc"))
{
Intent intent=new Intent(MainActivity.this,WelcomeUser.class);
startActivity(intent);
}
else
{
Toast.makeText(MainActivity.this, "Wrong Password, Try Again", Toast.LENGTH_SHORT).show();
}
}
});
}
else
{
Toast.makeText(MainActivity.this, "No Dialog Selected yet", Toast.LENGTH_SHORT).show();
}
}