-2
已經使用在requestDIalog.setPositiveButton
相同的功能,我使用的設置功能,我在MainActivity之外做出的。這個功能在onCreate(Bundle savedInstanceState)
這邊很合適。 DayDialog.lister〜startactivity(intent)中的代碼只是onCreate中正確函數的副本。但是,當我嘗試通過完全複製整個代碼來重複警報對話框中的相同功能時,它顯示錯誤,並說「proBar無法解析爲變量」 我如何解決此錯誤並重復相同的功能?請幫忙。的Android,單擊警告對話框按鈕後,我想這樣做在MainActivity
private AlertDialog makeRequestDialog(CharSequence title, CharSequence message,
CharSequence titleButtonYes, CharSequence titleButtonNo, CharSequence next) {
AlertDialog.Builder requestDialog = new AlertDialog.Builder(this);
requestDialog.setTitle(title);
requestDialog.setMessage(message);
requestDialog.setPositiveButton(titleButtonYes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
//From DayDialog.listener to StartActivity(intent), this section is already used in onCreation section with button setonclicklistener.
DayDialog.listener = new onDaySelectedListener() {
public void onDaySelected(int days) {
option1.setVisibility(Button.INVISIBLE);
initOption.setVisibility(Button.VISIBLE);
currentDay = days;
numWords=DayPreparation(currentDay);//It works!
index = 0;
setting(initOption,numWords,Button3,textView1,Words[index],proBar,Words,Means,index,currentDay,DayIndicator,false,option1);
}
};
Intent intent = new Intent(getApplicationContext(), DayDialog.class);
startActivity(intent);
}
});
`