我有两项活动:Account
和Transaction
。数据以Account
形式插入,我想在ACCOUNT NAME
的微调框中显示Transaction Activity
等特定数据。
数据库代码:
public List<String> getAllLabels(){
List<String> labels = new ArrayList<String>();
Cursor cursor = Mdatabase.query(DATABASE_TABLE1, new String[]
{KEY_BANKNAME},
null, null, null, null, null);
if (cursor.moveToFirst()) {
do {
labels.add(cursor.getString(1));
} while (cursor.moveToNext());
}
cursor.close();
return labels;
}
在Transaction Activity
:
private Spinner typerp;
public void loadSpinnerData() {
DatabaseAdapter db = new DatabaseAdapter(getApplicationContext());
List<String> lables = db.getAllLabels();
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, lables);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
typerp.setAdapter(dataAdapter);
}
当我打开Transaction Activity
时,应用程序崩溃了。请帮助。