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

  ViewVC Help
Powered by ViewVC 1.1.20