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 ExpansionListAdapter extends ArrayAdapter<ExpansionListItem> {
29 public ExpansionListAdapter(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.expansion_list, parent, false);
44 CheckBox expansionCheckBox =
45 (CheckBox)view.findViewById(R.id.expansionCheckBox);
46 ExpansionListItem item = getItem(position);
47 expansionCheckBox.setText(item.getTitle());
49 ListView listView = (ListView)parent;
50 expansionCheckBox.setChecked(listView.isItemChecked(position));
51 expansionCheckBox.setVisibility(View.VISIBLE);
53 TextView nCardsTextView =
54 (TextView)view.findViewById(R.id.nCardsTextView);
55 nCardsTextView.setText("" + item.getNCards());