1
我已經實現了以下函數與showDialog()和onDialogCreate()一起使用,但我希望每次都調用該方法,因爲它每次顯示對話框時都會計算文本視圖的文本。只有第一次調用Alert Builder?
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;
}
任何人都可以幫忙嗎?
完美;謝謝!至於成員變量,感謝提示,但它已經在我的待辦事項列表中。我只想讓對話框顯示正確的信息。 :-) – 2010-09-09 00:09:29