Dirty stub.
[wl-mobile.git] / src / pl / org / nowoczesnapolska / CatalogueAdapter.java
1 package pl.org.nowoczesnapolska;
2
3 import java.util.ArrayList;
4
5 import android.app.Activity;
6 import android.content.Context;
7 import android.util.Log;
8 import android.view.LayoutInflater;
9 import android.view.View;
10 import android.view.ViewGroup;
11 import android.widget.ArrayAdapter;
12 import android.widget.BaseAdapter;
13 import android.widget.TextView;
14
15 class CatalogueAdapter extends BaseAdapter {
16         private ArrayList<CatalogueEntry> items;
17         private Context ctx;
18         
19         public CatalogueAdapter(Context context, int textViewResourceId, ArrayList<CatalogueEntry> items) {
20                 this.items = items;
21                 this.ctx = context;
22         }
23
24                 @Override
25                 public int getCount() {
26                         // TODO Auto-generated method stub
27                         return items.size();
28                 }
29                 @Override
30                 public Object getItem(int position) {
31                         // TODO Auto-generated method stub
32                         return items.get(position);
33                 }
34                 @Override
35                 public long getItemId(int position) {
36                         return items.get(position).getId();
37                 }
38
39         @Override
40         public View getView(int position, View convertView, ViewGroup parent) {
41                 View v = convertView;
42                 if (v == null) {
43                         LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
44                     v = vi.inflate(R.layout.catalogue_row, null);
45                 }
46                 CatalogueEntry o = items.get(position);
47                 if (o != null) {
48                                 Log.d("not null", "not null");
49                         TextView tt = (TextView) v.findViewById(R.id.id);
50                         TextView bt = (TextView) v.findViewById(R.id.name);
51                         if (tt != null) {
52                               tt.setText("Name: "+o.getName());                            }
53                         if(bt != null){
54                               bt.setText("Type: "+ o.getType());
55                         }
56                 }
57                 Log.d("dalej", "dalej");
58                 return v;
59         }
60 }