private void refreshAccounts() { ListView accountsList = (ListView) findViewById(R.id.listView); ArrayAdapter<AccountLine> adapter = new ArrayAdapter<AccountLine>( this, android.R.layout.simple_list_item_1, accountRepository.getAccounts()); accountsList.setAdapter(adapter); }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); ListView accountsList = (ListView) findViewById(R.id.listView); AccountLine selectedLine = (AccountLine) accountsList.getAdapter().getItem(info.position); accountRepository.remove(selectedLine); refreshAccounts(); return true; }