Created
May 6, 2020 13:48
-
-
Save dariadobsai/1863a31032c8065c0bb0417c23881ac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SandwichAdapter extends ArrayAdapter<Sandwich> { | |
public SandwichAdapter(Context context, List<Sandwich> sandwiches) { | |
super(context, 0, sandwiches); | |
} | |
@Override | |
@NonNull | |
public View getView(int position, View convertView, @NonNull ViewGroup parent) { | |
Sandwich sandwich = getItem(position); | |
if (convertView == null) { | |
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); | |
} | |
TextView sandwichMainName = convertView.findViewById(R.id.sandwich_name); | |
ImageView sandwichImage = convertView.findViewById(R.id.sandwich_image); | |
sandwichMainName.setText(sandwich.getMainName()); | |
Picasso.get() | |
.load(sandwich.getImage()) | |
.into(sandwichImage); | |
return convertView; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment