0
下面的代碼會得到錯誤「不能引用在不同方法中定義的內部類中的非最終變量myid」,爲什麼?謝謝!爲什麼會導致錯誤「無法引用非最終變量」?
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();
}
可以黑帶你這個問題,看看如果你有時間http://stackoverflow.com/questions/17388373/get-text-from-textview-w-按鈕功能於定製列表視圖/ 17388422?noredirect = 1個#comment25243990_17388422。這是否正確,因爲我不確定我的答案的第二部分 – Raghunandan