1 /* AppSearchListAdapter.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;
29 * Created by pk910 on 19.01.2016.
31 public class AppSearchListAdapter extends ArrayAdapter<AppSearchListItem> {
32 private Context context;
33 private int layoutResourceId;
34 private ArrayList<AppSearchListItem> data = new ArrayList<AppSearchListItem>();
36 public AppSearchListAdapter(Context context, int layoutResourceId, ArrayList<AppSearchListItem> data) {
37 super(context, layoutResourceId, data);
38 this.layoutResourceId = layoutResourceId;
39 this.context = context;
44 public View getView(int position, View convertView, ViewGroup parent) {
45 View row = convertView;
46 RecordHolder holder = null;
49 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
50 row = inflater.inflate(layoutResourceId, parent, false);
52 holder = new RecordHolder(row);
55 holder = (RecordHolder) row.getTag();
58 final AppSearchListAdapter that = this;
59 final AppSearchListItem item = data.get(position);
61 holder.resultTitle.setText(item.getTitle());
62 holder.resultDescription.setText(item.getDescription());
67 static class RecordHolder {
69 TextView resultDescription;
71 public RecordHolder(View view) {
72 this.resultTitle = (TextView) view.findViewById(R.id.resultTitle);
73 this.resultDescription = (TextView) view.findViewById(R.id.resultDescription);