全新的Android和Java的...獲取從受保護的方法變量值另一類
我有一個protected
方法Class2
如下:
protected void onListClick(List 2, View view, int position, long id)
{
.....
int Count = cursor.GetInt(countIndex);
........
}
我需要從Count
訪問值Class2
。
Class1
(其中試圖訪問從Class2中值)我有int getValue = Class2.Count;
這是爲什麼不工作?
研究**局部**變量是什麼。 –
'計數'的範圍只在聲明的方法內。如果您需要從另一個類訪問它,請將其作爲類成員在方法外部聲明。 –