forked from AI1234567891012/MC-in-a-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VersionAdapter.java
47 lines (37 loc) · 1.47 KB
/
VersionAdapter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.aof.mcinabox.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.aof.mcinabox.R;
import com.aof.mcinabox.model.Profile;
import java.util.List;
public class VersionAdapter extends ArrayAdapter<Profile> {
public VersionAdapter(@NonNull Context context, @NonNull List<Profile> profiles) {
super(context, 0, profiles);
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.version_row, parent, false);
}
Profile profile = getItem(position);
ImageView icon = convertView.findViewById(R.id.icon);
TextView name = convertView.findViewById(R.id.name);
TextView description = convertView.findViewById(R.id.description);
icon.setImageResource(R.drawable.grass);
name.setText(profile.getName());
description.setText(profile.getDescription());
return convertView;
}
@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
return getView(position, convertView, parent);
}
}