0
我在textview上設置了警告對話框,我在這裏使用了String數組,現在如何選中沒有任何項目被選中或沒有選中,如果沒有項目選擇它不應該提交..請檢查我的代碼片段代碼在下面..感謝提前。 。如何檢查選定的警報對話框項目?
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"};
final ArrayAdapter<String> 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());
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();
final String uname=username.getText().toString();
if(!isValidUserName(uname))
{
username.setError("Invalid User Name");
}
final String fname=firstname.getText().toString();
if(!isValidFirstName(fname))
{
firstname.setError("Invalid First Name");
}
final String lname=lastname.getText().toString();
if(!isValidLastName(lname))
{
lastname.setError("Invalid Last Name");
}
}
else
{
Toast.makeText(getApplicationContext(), "Fill the details", Toast.LENGTH_LONG).show();
}
break;
}
});