0% found this document useful (0 votes)
4 views2 pages

Menu Tapes

The document is a Java class named MenuTapes that extends RecyclerView.Adapter to manage a list of pizza items in a menu. It includes methods for creating view holders, binding data to views, and determining the item count, although the item count method currently returns zero. The class also sets background images for different pizza types based on their position in the list.

Uploaded by

dana.shaked15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Menu Tapes

The document is a Java class named MenuTapes that extends RecyclerView.Adapter to manage a list of pizza items in a menu. It includes methods for creating view holders, binding data to views, and determining the item count, although the item count method currently returns zero. The class also sets background images for different pizza types based on their position in the list.

Uploaded by

dana.shaked15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.example.my1.

Menu;

import android.icu.util.ULocale;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.view.menu.MenuAdapter;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.example.my1.R;
import com.example.my1.tapes.PizzaList;

import java.util.ArrayList;
import java.util.Locale;

public class MenuTapes extends


RecyclerView.Adapter<MenuTapes.ViewHolder> {
ArrayList<PizzaList>pizza_Lists;

public MenuTapes(ArrayList<PizzaList> pizza_Lists) {


this.pizza_Lists = pizza_Lists;
}

@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
int viewType) {
View inflate=
LayoutInflater.from(parent.getContext()).inflate(R.layout.,parent,fal
se);
return new ViewHolder(inflate);
}

@Override
public void onBindViewHolder(@NonNull MenuTapes.ViewHolder
holder, int position) {

holder.pizzatapes.setText(pizza_Lists.get(position).getTitle());
String picHa = "";
switch (position) {
case 0: {
picHa = "pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background1));
}
case 1: {
picHa = "olive pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background2));
}
case 2: {
picHa = "corn pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background3));
}
case 3: {
picHa = "mushroom pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background4));
}
case 4: {
picHa = "sirene pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background5));
}
case 5: {
picHa = "pepperoni pizza";

holder.PizzaLayout.setBackground(ContextCompat.getDrawable(holder.ite
mView.getContext(), R.drawable.tapes_piz_background6));
}
}

int drawableResourceId =
holder.itemView.getContext().getResources().getIdentifier(picHa,
"drawable", holder.itemView.getContext().getPackageName());

@Override
public int getItemCount() {
return 0;
}

public class ViewHolder extends RecyclerView.ViewHolder {


TextView pizzatapes;
ImageView pizzapic;
ConstraintLayout PizzaLayout;

public ViewHolder(@NonNull View itemView) {


super(itemView);
pizzatapes= itemView.findViewById(R.id.pizza_tape);
pizzapic= itemView.findViewById(R.id.pizza_pic);
PizzaLayout= itemView.findViewById(R.id.pizzas);
}
}
}

You might also like