Android 在静态类中填充非静态变量(微调器)
我试图做到这一点:Android 在静态类中填充非静态变量(微调器),android,variables,static,non-static,Android,Variables,Static,Non Static,我试图做到这一点: 在DatePickerDialog中,用户设置日期 日期将在微调器中写入 问题在于,包含OnDateSet方法的DatePickerFragment类是静态的,而微调器是非静态的。在OnDateSet方法中,我需要将项添加到适配器并调用方法Spinner.setSelection(inti) 错误在这一行: firstdate = day1 + "/" + month1 + "/" + year1; 有人能帮我吗 提前感谢。您也可以在片段中声明它,并有一个返回其值的gett
firstdate = day1 + "/" + month1 + "/" + year1;
有人能帮我吗
提前感谢。您也可以在片段中声明它,并有一个返回其值的getter
public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
private int firstdate;
// .. other code
public int getFirstDate() {
return firstdate;
}
}
从活动中,可以像
mDialogInstance.getFirstDate()那样调用它代码>未声明firstdate是的,它在类之外
public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
private int firstdate;
// .. other code
public int getFirstDate() {
return firstdate;
}
}