1package jme3test.android;
2
3import android.content.Context;
4import android.view.LayoutInflater;
5import android.view.View;
6import android.view.View.OnClickListener;
7import android.view.ViewGroup;
8import android.widget.BaseAdapter;
9import android.widget.TextView;
10import java.util.List;
11
12/**
13 * The view adapter which gets a list of LaunchEntries and displaqs them
14 * @author larynx
15 *
16 */
17public class DemoLaunchAdapter extends BaseAdapter implements OnClickListener
18{
19
20    private Context context;
21
22    private List<DemoLaunchEntry> listDemos;
23
24    public DemoLaunchAdapter(Context context, List<DemoLaunchEntry> listDemos) {
25        this.context = context;
26        this.listDemos = listDemos;
27    }
28
29    public int getCount() {
30        return listDemos.size();
31    }
32
33    public Object getItem(int position) {
34        return listDemos.get(position);
35    }
36
37    public long getItemId(int position) {
38        return position;
39    }
40
41    public View getView(int position, View convertView, ViewGroup viewGroup) {
42        DemoLaunchEntry entry = listDemos.get(position);
43        if (convertView == null) {
44            LayoutInflater inflater = (LayoutInflater) context
45                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
46            convertView = inflater.inflate(R.layout.demo_row, null);
47        }
48        TextView tvDemoName = (TextView) convertView.findViewById(R.id.tvDemoName);
49        tvDemoName.setText(entry.getName());
50
51        TextView tvDescription = (TextView) convertView.findViewById(R.id.tvDescription);
52        tvDescription.setText(entry.getDescription());
53
54        return convertView;
55    }
56
57    @Override
58    public void onClick(View view) {
59        DemoLaunchEntry entry = (DemoLaunchEntry) view.getTag();
60
61
62
63
64    }
65
66    private void showDialog(DemoLaunchEntry entry) {
67        // Create and show your dialog
68        // Depending on the Dialogs button clicks delete it or do nothing
69    }
70
71}
72
73