Answer the question
In order to leave comments, you need to log in
Why does SimpleCursorAdapter have this behavior?
There is such a code.
public void refreshTransactions(){
Cursor cursor = dbHelper.getAllTransactions(db);
String[] from = new String[] {"a.name","c.name","t.date", "t.amount"};
int[] to = new int[] { R.id.tvAccount, R.id.tvCategory, R.id.tvDate, R.id.tvAmount };
SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,R.layout.item_journal_transaction,
cursor,from,to,0);
ListView listView = (ListView)findViewById(R.id.list_JournalTransaction);
listView.setAdapter(cursorAdapter);
}
//из dbHelper
public Cursor getAllTransactions(SQLiteDatabase db) {
return db.query(TableNames.VIEW_TRANSACTIONS,
null,null,null,null,null,null);
}
//строка создающая представление
String VIEW_TRANSACTIONS = "" +
"create view \n" +
TableNames.VIEW_TRANSACTIONS+" "+
"as select t._id, t.date,a.name,c.name, t.amount\n" +
"from accounts a, categorys c, transactions t\n" +
"where t.categorys_id = c._id\n" +
"and t.accounts_id = a._id;";
Answer the question
In order to leave comments, you need to log in
I understood what the problem was, looking at the view screen, or rather at the names of the columns.
Solved like this:
String[] from = new String[] {"name","name:1","date", "amount"};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question