2 // Copyright (c) 2013 Motoyuki Kasahara
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package jp.sourceforge.gamerandomizer;
19 import android.content.Context;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.ArrayAdapter;
24 import android.widget.CheckBox;
25 import android.widget.ListView;
26 import android.widget.TextView;
28 public class CardListAdapter extends ArrayAdapter<CardListItem> {
29 public CardListAdapter(Context context) {
34 public View getView(int position, View convertView, ViewGroup parent) {
37 if (convertView == null) {
38 LayoutInflater inflater = LayoutInflater.from(getContext());
39 view = inflater.inflate(R.layout.card_list, parent, false);
44 CheckBox cardCheckBox =
45 (CheckBox)view.findViewById(R.id.cardCheckBox);
46 CardListItem item = getItem(position);
47 cardCheckBox.setText(item.getTitle());
49 ListView listView = (ListView)parent;
50 cardCheckBox.setChecked(listView.isItemChecked(position));
51 cardCheckBox.setVisibility(View.VISIBLE);
53 TextView cardPriceTextView =
54 (TextView)view.findViewById(R.id.cardPriceTextView);
55 cardPriceTextView.setText(item.getPrice());
57 TextView cardIndexTextView =
58 (TextView)view.findViewById(R.id.cardIndexTextView);
59 cardIndexTextView.setText(String.format("#%d", position + 1));
61 TextView expansionNameTextView =
62 (TextView)view.findViewById(R.id.expansionNameTextView);
63 expansionNameTextView.setText(item.getExpansion());