queryType.setView(myView); queryType.setPositiveButton("Find", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub int select = group.getCheckedRadioButtonId(); View tmp = group.findViewById(select); int idx = group.indexOfChild(tmp); // Toast.makeText(viewHistory.this, "" + idx, Toast.LENGTH_LONG).show(); switch (idx) { case 0: allHistory(); break; case 1: Calendar temp = Calendar.getInstance(); temp.set(date1.getYear(), date1.getMonth() + 1, date1.getDayOfMonth()); Long temp1 = temp.getTimeInMillis(); temp.set(date2.getYear(), date2.getMonth() + 1, date2.getDayOfMonth());