我试图创建一个项目列表,每个i和j变量都不同。我的代码是:
if (i == 0) {
if (j == 0) {
final CharSequence[] items = {"4:45", "5:00"}
} else if (j == 1) {
final CharSequence[] items = {"4:43", "4:58"}
} else if (j == 2) {
final CharSequence[] items = {"4:41", "4:56"}
} else {
final CharSequence[] items = {"4:38", "4:53"}
}
...
new AlertDialog.Builder(this)
.setTitle("Hours")
.setItems(items,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
// getStation(i);
}
})
.show();
}
我在一行中得到一个错误.setItems(items,:
items cannot be resolved
我认为编译器认为CharSequence[] items可能未初始化之类的东西...如何使该程序运行?
忽然笑
猛跑小猪
繁花如伊