Created
May 6, 2009 20:20
-
-
Save brindy/107718 to your computer and use it in GitHub Desktop.
A sample custom ListAdapter for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setListAdapter(new BaseAdapter() { | |
public int getCount() { | |
return expenses.size(); | |
} | |
public Object getItem(int position) { | |
return expenses.get(position); | |
} | |
public long getItemId(int position) { | |
Expense expense = expenses.get(position); | |
return expense.getId(); | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
Log.d(getClass().getName(), "getView()"); | |
Expense exp = expenses.get(position); | |
View view = View.inflate(context, R.layout.expenses_row, null); | |
TextView value = (TextView) view.findViewById(R.id.value); | |
value.setText(mDecimalFormat.format(exp.getValue())); | |
TextView desc = (TextView) view.findViewById(R.id.description); | |
desc.setText(exp.getDescription()); | |
return view; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment