double cal;
double rcarbohydrate;
double rfat;
double rprotein;
public AdapterDB(double cal, double rcarbohydrate, double rfat, double rprotein, Context ctx)
{
this.cal = cal;
this.rcarbohydrate = rcarbohydrate;
this.rfat = rfat;
this.rprotein = rprotein;
this.context = ctx;
DBHelper = new DatabaseHelper (context);
Log.v("", "cal1 " + cal);
Log.v("", "cal1 " + rcarbohydrate);
Log.v("", "cal1 " + rfat);
Log.v("", "cal" + rprotein);
}
public void generateSomething()
{
Log.i("", "cal2 " + cal);
Log.i("", "cal2 " + rcarbohydrate);
Log.i("", "cal2 " + rfat);
Log.i("", "cal2 " + rprotein);
}
它無法獲得值。 cal1得到的值,但cal2爲0.0爲什麼?任何想法如何解決這個問題?謝謝。實際cal = 2500.00 rcarbohydrate = 350.50 rfat = 45.90 rprotein = 156.90對構造函數theres是值,但是當我想在另一個函數上使用它時,它是零(Android)
你確定你打給'generateSomething()'在類的同一個實例上? –
是的,在一個類 – Michelle
一個類,但有多少個類的實例?你能告訴你如何調用新的AdapterDB(...)和generateSomething()。 (請參閱@Mocialov Boris的答案) – FunkTheMonk