我想创建一个项目列表,不同的每个我和j变量。我的代码是:变量无法解析
items cannot be resolved
我认为,编译器认为该CharSequence[] items
可能不会被初始化:
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,
得到一个错误或者其他什么... 我怎样才能让这个程序运行?
提示:当编译器认为它没有被初始化时,他会告诉你它没有被初始化。如果它说“无法解决”,那么这意味着它无法在任何适用范围内找到该变量。 – 2010-04-06 14:41:56