I need to set the return value of this method to be the item selected in a Single Choice Dialog...
However, i cannot set the value of retVal because it apparently needs to be final (therefore cannot be changed)
Is there any way to do this without using global variables?
private String getSaleType()
{
String retVal = "";
final String[] TYPES = {"Cash Sale", "Sales Order"};
AlertDialog.Builder choose = null;
try
{
choose = new AlertDialog.Builder(this);
choose.setIcon(R.drawable.firstdroidicon);
choose.setTitle("Sale Type");
choose.setMessage("Type Of Sale?");
choose.setSingleChoiceItems(TYPES, currentItem, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
Log.i("Selected", TYPES[which]);
}
});
choose.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
retVal = TYPES[which];
}
});
}
catch(Exception e)
{
messageBox("getSaleType", e.getMessage());
}
return retVal;
}