I have implemented the following function to be used with showDialog() and onDialogCreate(), but I would like the method to be called each time because it calculates the text of a text view every time the dialog is displayed.
private AlertDialog overallScoreDialog(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.overall_score_dialog,
(ViewGroup) findViewById(R.id.overall_score_dialog_layout_root));
alert.setTitle("Results");
TextView tv = (TextView) layout.findViewById(R.id.overallscoreresults);
ScoreCalculator sc = new ScoreCalculator(this, calculatorVO);
tv.setText(Double.toString(sc.getTotalScore()));
alert.setView(layout);
alert.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
return;
}
});
AlertDialog ad = alert.create();
return ad;
}
Can anyone help?