此代码是单击列表视图时弹出的上下文菜单的一部分。我试图通过是否选中CheckBox来获取用户结果。问题是我创建的字符串无法解析。这个字符串怎么解决不了?
下面是代码:
final CheckBox input11 = (CheckBox) textEntryView2.findViewById(R.id.checkBoxResult);
alert2.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String blazeIt = lvItems.getItemAtPosition(menuInfo.position).toString();
String turntupheho = blazeIt.replace(" --COMPLETE", "");
String evenmoreturnt = turntupheho.replace(" --INCOMPLETE", "");
if (input11.isChecked()) {
String bigbutt = " --COMPLETE";
} else {
String bigbutt = " -INCOMPLETE";
}
items.set(menuInfo.position, evenmoreturnt + bigbutt); //Cannot resolve symbol 'bigbutt'
itemsAdapter.notifyDataSetChanged();
writeItems();
}
}
);
编辑:对不起简单的错误(忘了声明字符串);我还在学习。感谢大家的快速回复。
先生,在if(input11.isChecked())块之前声明'String bigbutt;'。 –
我希望那些不是你的实际变量名称 –
http://www.java-made-easy.com/variable-scope.html –