/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/TimetableListAdapter.java
ViewVC logotype

Contents of /android/TrainInfo/src/dk/thoerup/traininfo/TimetableListAdapter.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 367 - (show annotations) (download)
Wed Sep 30 11:20:53 2009 UTC (14 years, 7 months ago) by torben
File size: 1875 byte(s)
Remove unnecessary log statement
1 package dk.thoerup.traininfo;
2
3 import java.util.List;
4
5 import android.content.Context;
6 import android.view.LayoutInflater;
7 import android.view.View;
8 import android.view.ViewGroup;
9 import android.widget.BaseAdapter;
10 import android.widget.TextView;
11
12 public class TimetableListAdapter extends BaseAdapter {
13
14 private List<TimetableBean> timetable;
15 LayoutInflater inflater;
16 Context context;
17
18 @Override
19 public boolean isEnabled(int position) {
20 return false;
21 }
22
23 public TimetableListAdapter(Context context) {
24 super();
25 this.context = context;
26
27 inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
28 }
29
30 public void setTimetable(List<TimetableBean> timetable) {
31 this.timetable = timetable;
32 notifyDataSetChanged();
33 }
34
35 @Override
36 public int getCount() {
37 if (timetable != null)
38 return timetable.size();
39 else
40 return 0;
41 }
42
43 @Override
44 public Object getItem(int position) {
45 return null;
46 }
47
48 @Override
49 public long getItemId(int position) {
50 return position;
51 }
52
53 @Override
54 public View getView(int position, View convertView, ViewGroup parent) {
55 TimetableBean timetableBean = timetable.get(position);
56
57 View root = inflater.inflate(R.layout.timetablerow , parent, false);
58
59 TextView station = (TextView) root.findViewById(R.id.Station);
60 station.setText(timetableBean.getStation());
61
62 TextView arrival = (TextView) root.findViewById(R.id.Arrival);
63 arrival.setText(timetableBean.getArrival());
64
65 TextView departure = (TextView) root.findViewById(R.id.Departure);
66 departure.setText(timetableBean.getDeparture());
67
68
69 if (timetableBean.isCurrent()) {
70 final int bgcolor = 0xFFFFFFFF;
71 final int fgcolor = 0xFF000000;
72
73 station.setTextColor(fgcolor);
74 arrival.setTextColor(fgcolor);
75 departure.setTextColor(fgcolor);
76 root.setBackgroundColor(bgcolor);
77 }
78
79 return root;
80 }
81
82 }

  ViewVC Help
Powered by ViewVC 1.1.20