我无法从我的 SQLite 数据库中获取我的 ArrayList 以显示在文本视图中。这个想法是让它成为一个“历史”页面,这样用户就可以看到他们过去的条目。当我这样做时tv.setText(db.getAllBalance)
,我得到的只是崩溃,logcat 会一遍又一遍地显示我的项目包名称,后跟@4f58a392 之类的东西。这是我完成我的应用程序的最后一步,它正在苦苦挣扎。任何援助将不胜感激。
我的数据库:
//Getting All Balance
public List<Balance> getAllBalance(){
List<Balance> balanceList = new ArrayList<Balance>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_BALANCE;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Balance balance = new Balance();
balance.setID(Integer.parseInt(cursor.getString(0)));
balance.setAmount(cursor.getFloat(1));
// Adding balance to list
balanceList.add(balance);
} while (cursor.moveToNext());
}
// return contact list
return balanceList;
}
我的历史课:
public class History extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.history);
final DatabaseHandler db = new DatabaseHandler(this);
TextView tv = (TextView) findViewById(R.id.tvSQLinfo);
Log.d("testing", "reading wallet " + db.getAllBalance());
tv.setText((CharSequence) db.getAllBalance());
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
AdView adview = (AdView) findViewById(R.id.adView);
AdRequest re = new AdRequest();
//re.setTesting(true);
adview.loadAd(re);
}
}
我有发布“坏问题”的糟糕历史。但我保证,我搜索和搜索,只是找不到解决方案。