private TableLayout table;
private ProgressBar progress;
private TextView text_date;
private TableLayout table;
private ProgressBar progress;
private TextView text_date;
text_date = findViewById(R.id.new_transaction_date);
text_descr = findViewById(R.id.new_transaction_description);
text_date = findViewById(R.id.new_transaction_date);
text_descr = findViewById(R.id.new_transaction_description);
table = findViewById(R.id.new_transaction_accounts_table);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
table = findViewById(R.id.new_transaction_accounts_table);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
hook_text_change_listener(acc_name_view);
hook_text_change_listener(amount_view);
// Log.d("swipe", "hooked to row "+i);
hook_text_change_listener(acc_name_view);
hook_text_change_listener(amount_view);
// Log.d("swipe", "hooked to row "+i);
- private void hook_autocompletion_adapter(final TableRow row) {
- String[] from = {"name"};
+ private void hook_autocompletion_adapter(final AutoCompleteTextView view, final String table, final String field) {
+ String[] from = {field};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to, 0);
adapter.setStringConversionColumn(1);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to, 0);
adapter.setStringConversionColumn(1);
String str = constraint.toString().toUpperCase();
Log.d("autocompletion", "Looking for "+str);
String str = constraint.toString().toUpperCase();
Log.d("autocompletion", "Looking for "+str);
- Cursor matches = db.rawQuery("SELECT name FROM accounts WHERE UPPER(name) LIKE '%'||?||'%' ORDER BY name;", new String[]{str});
+ Cursor matches = db.rawQuery(String.format("SELECT %s FROM %s WHERE UPPER(%s) LIKE '%%'||?||'%%' ORDER BY 1;", field, table, field), new String[]{str});
- String name = matches.getString(0);
- Log.d("autocompletion-match", name);
- c.newRow().add(i++).add(name);
+ String match = matches.getString(0);
+ Log.d("autocompletion", String.format("match: %s", match));
+ c.newRow().add(i++).add(match);