@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { DecimalFormat decimalFormat = new DecimalFormat("##0.##"); Assignment asg = (Assignment) adapter.getItem(position); String title = asg.name; String detail = ""; if (asg.type.equals("Cat")) { detail = "Score: " + decimalFormat.format(asg.score) + " / " + decimalFormat.format(asg.total) + "\nPercentage: " + (asg.percent != null && asg.percent.length() > 1 ? asg.percent : "100.00%") + "\nGrade: " + asg.letter + "\n\nCourse Weight: " + decimalFormat.format(Double.parseDouble(asg.weight)) + "%"; } else { detail = "Score: " + decimalFormat.format(asg.score) + " / " + decimalFormat.format(asg.total) + "\nPercentage: " + asg.percent + "\nGrade: " + asg.letter + "\n\nCategory: " + asg.category + "\nDue Date: " + asg.date; } AlertDialog.Builder builder = new AlertDialog.Builder(CourseDetailActivity.this); builder.setTitle(title); builder.setMessage(detail); builder.setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {} }); builder.show(); }