I have set alert dialog on textview's onclicklistener
, and there I have added some items using array adapter. Now what I want to do is check if the user selects an item from the alert dialog and clicks on submit. It should submit, otherwise not. But as per my if
I select or not it displays message fill the details.
boolean isSetDay = false;
sp3=(TextView)findViewById(R.id.daydates);
btnsubmit=(Button)findViewById(R.id.btnreg);
final String[] items = new String[] {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
adapter123 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, items);
sp3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View w) {
new AlertDialog.Builder(RegistrationForm.this)
.setTitle("Select Day")
.setAdapter(adapter123, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sp3.setText(adapter123.getItem(which).toString());
isSetDay=true;
dialog.dismiss();
}
}).create().show();
}
});
btnsubmit.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(emailtext.getText().toString().trim().length() > 0 && passtext.getText().toString().trim().length() > 0 && confirmpass.getText().toString().trim().length() > 0 && username.getText().toString().trim().length() > 0 && firstname.getText().toString().trim().length() > 0 && lastname.getText().toString().trim().length() > 0 && isSetDay==true && isSetMonth==true && isSetYear==true && isSetPro==true)
{
isSetDay=false;
isSetMonth=false;
isSetYear=false;
isSetPro=false;
new AttemptLogin().execute();
}
else
{
Toast.makeText(getApplicationContext(), "Fill the details", Toast.LENGTH_LONG).show();
}
break;
}
});