Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CoinlogoAdapter extends PagerAdapter {
- private Context context;
- private List<Coinlogo> listCoin;
- public CoinlogoAdapter(Context context, List<Coinlogo> listCoin) {
- this.context = context;
- this.listCoin = listCoin;
- }
- @Override
- public int getCount() {
- return listCoin.size();
- }
- @Override
- public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
- super.destroyItem(container, position, object);
- }
- @Override
- public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
- return view.equals(object);
- }
- @Override
- public int getItemPosition(@NonNull Object object) {
- return super.getItemPosition(object);
- }
- @NonNull
- @Override
- public Object instantiateItem(@NonNull ViewGroup container, int position) {
- View view = LayoutInflater.from(context).inflate(R.layout.item_coin, container, false);
- ImageView ivImage = view.findViewById(R.id.iv_image);
- TextView tvTitle = view.findViewById(R.id.tv_title);
- TextView tvYear = view.findViewById(R.id.tv_year);
- TextView tvStamp = view.findViewById(R.id.tv_stamp);
- TextView tvCondition = view.findViewById(R.id.tv_condition);
- TextView tvKant = view.findViewById(R.id.tv_kant);
- TextView tvMagnet = view.findViewById(R.id.tv_magnet);
- TextView tvGurt = view.findViewById(R.id.tv_gurt);
- TextView tvPrice = view.findViewById(R.id.tv_price);
- ivImage.setImageResource(listCoin.get(position).getImage());
- tvTitle.setText(listCoin.get(position).getNominal());
- tvYear.setText(listCoin.get(position).getYear());
- tvStamp.setText(listCoin.get(position).getStamp());
- tvCondition.setText(listCoin.get(position).getCondition());
- tvKant.setText(listCoin.get(position).getKant());
- tvMagnet.setText(listCoin.get(position).getMagnet());
- tvGurt.setText(listCoin.get(position).getGurt());
- tvPrice.setText(listCoin.get(position).getPrice());
- view.setOnClickListener(v -> Toast.makeText(context, "" + listCoin, Toast.LENGTH_SHORT).show());
- container.addView(view);
- return view;
- }
- }
Add Comment
Please, Sign In to add comment