I like to display one dialog box in the click event of another dialog box.My code is given below.But it shows an error- Syntax error on token ")", ; expected,Syntax error on token ")", ; expected.Can anybody clear this problem
final CharSequence[] PhoneModels = {"Pub Date", "Catagory", "Amount"}; final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); alt_bld.setTitle("Select An Option");
alt_bld.setSingleChoiceItems(PhoneModels, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { //UpdateDisplay(); // dialog.dismiss(); getApplicationContext(); if(PhoneModels[item]=="Pub Date") {@Override protected Dialog onCreateDialog(int id) { Calendar c = Calendar.getInstance(); int cyear = c.get(Calendar.YEAR); int cmonth = c.get(Calendar.MONTH); int cday = c.get(Calendar.DAY_OF_MONTH); switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, cyear, cmonth, cday); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { // onDateSet method public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { String date_selected = String.valueOf(monthOfYear+1)+" /"+String.valueOf(dayOfMonth)+" /"+String.valueOf(year); Toast.makeText(ExampleApp.this, "Selected Date is ="+date_selected, Toast.LENGTH_SHORT).show(); } }; Toast.makeText(getApplicationContext(), " will be here", Toast.LENGTH_SHORT).show(); } else if(PhoneModels[item]=="Catagory") {Toast.makeText(getApplicationContext(), " will not be here", Toast.LENGTH_SHORT).show(); } else {Toast.makeText(getApplicationContext(), "It will be here", Toast.LENGTH_SHORT).show(); } } }); AlertDialog alert = alt_bld.create(); alert.show(); // display UI }