下面的代码得到错误“Cannot reference an non-final variable myid inside an internal class defined in a different method”,为什么?谢谢!
private void DeleteSingleSMS(long myid){
AlertDialog.Builder builder = new Builder(this);
builder.setMessage(getString(R.string.DeleteContent));
builder.setTitle(getString(R.string.DeleteTitle));
builder.setPositiveButton(getString(R.string.DeleteOK), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String uri = "content://sms/" +myid;
getContentResolver().delete(Uri.parse(uri), null, null);
}
});
builder.setNegativeButton(getString(R.string.DeleteCancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
}