1 /* MensaTagesplanListAdapter.java
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.fragments;
17 import android.content.Context;
18 import android.view.LayoutInflater;
19 import android.view.View;
20 import android.view.ViewGroup;
21 import android.widget.ArrayAdapter;
22 import android.widget.TextView;
24 import java.util.ArrayList;
26 import de.dhbwloe.campusapp.R;
27 import de.dhbwloe.campusapp.mensaplan.*;
30 * Created by pk910 on 24.01.2016.
33 public class MensaTagesplanListAdapter extends ArrayAdapter<de.dhbwloe.campusapp.mensaplan.MensaTagesplan> {
34 private Context context;
35 private int layoutResourceId;
36 private ArrayList<de.dhbwloe.campusapp.mensaplan.MensaTagesplan> data = new ArrayList<de.dhbwloe.campusapp.mensaplan.MensaTagesplan>();
38 public MensaTagesplanListAdapter(Context context, int layoutResourceId, ArrayList<de.dhbwloe.campusapp.mensaplan.MensaTagesplan> data) {
39 super(context, layoutResourceId, data);
40 this.layoutResourceId = layoutResourceId;
41 this.context = context;
46 public View getView(int position, View convertView, ViewGroup parent) {
47 View row = convertView;
48 RecordHolder holder = null;
51 LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
52 row = inflater.inflate(layoutResourceId, parent, false);
54 holder = new RecordHolder(row);
57 holder = (RecordHolder) row.getTag();
60 final MensaTagesplanListAdapter that = this;
61 final de.dhbwloe.campusapp.mensaplan.MensaTagesplan item = data.get(position);
63 if(holder.txtMenueName != null)
64 holder.txtMenueName.setText(item.getMenuName());
65 if(holder.txtName != null)
66 holder.txtName.setText(item.getName());
67 if(holder.txtPrice != null)
68 holder.txtPrice.setText(item.getFormatedRolePrice());
73 static class RecordHolder {
74 TextView txtMenueName;
78 public RecordHolder(View view) {
79 this.txtMenueName = (TextView) view.findViewById(R.id.txtMenueName);
80 this.txtName = (TextView) view.findViewById(R.id.txtName);
81 this.txtPrice = (TextView) view.findViewById(R.id.txtMenuePrice);