bonjour à tout les développeurs.
j'essaye de construire une liste view à partir de plusieurs tutos car je suis débutant .
je voudrais arriver à faire comme sur l'image mais pour l'instant ce n'est pas le cas

Nom : maliste.png
Affichages : 171
Taille : 346,7 Ko

je suis perdu perdu je tourne en rond. si vous pouviez me dire comment faire pour résoudre cela erreur contexte et erreur this
pardonné moi pour ce placard que je pose

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package insecte.programme.ulision.ui.home.ordre.adapter;
 
import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
 
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
 
import java.util.List;
 
import insecte.programme.ulision.R;
import insecte.programme.ulision.ui.home.ordre.insectes_Details;
import insecte.programme.ulision.ui.home.ordre.les_hymenopteres.Hymenopteres_Un_Trois;
import insecte.programme.ulision.ui.home.ordre.model.RecentlyViewed;
 
public class RecentlyViewedAdapter extends RecyclerView.Adapter<RecentlyViewedAdapter.RecentlyViewedViewHolder> {
 
    Hymenopteres_Un_Trois context;
    List<RecentlyViewed> recentlyViewedList;
 
    public RecentlyViewedAdapter(Hymenopteres_Un_Trois context, List<RecentlyViewed> recentlyViewedList) {
        this.context = context;
        this.recentlyViewedList = recentlyViewedList;
    }
 
************** ici une erreur ******  pour (context) seulement ****************
 message 
Required type:
Context
Provided:
Hymenopteres_Un_Trois
 ****************
 
    @NonNull
    @Override
    public RecentlyViewedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.items_liste_insectes, parent, false);
 
        return new RecentlyViewedViewHolder(view);
    }
 
    @Override
    public void onBindViewHolder(@NonNull RecentlyViewedViewHolder holder, @SuppressLint("RecyclerView") final int position) {
 
        holder.name.setText(recentlyViewedList.get(position).getName());
        holder.description.setText(recentlyViewedList.get(position).getDescription());
        holder.price.setText(recentlyViewedList.get(position).getPrice());
        holder.qty.setText(recentlyViewedList.get(position).getQuantity());
        holder.unit.setText(recentlyViewedList.get(position).getUnit());
        holder.bg.setBackgroundResource(recentlyViewedList.get(position).getImage_insectes ());
 
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
 
 
************** ici une erreur message ******  Intent i=new Intent(context, insectes_Details.class);   ****************
Cannot resolve constructor  'Intent(insecte.programme.ulision.ui.home.ordre.les_hymenopteres.Hymenopteres_Un_Trois, java.lang.Class<insecte.programme.ulision.ui.home.ordre.insectes_Details>)'
************
                Intent i=new Intent(context, insectes_Details.class); 
                i.putExtra("name", recentlyViewedList.get(position).getName());
                i.putExtra("image", recentlyViewedList.get(position).getBigimageurl());
                i.putExtra("price",recentlyViewedList.get(position).getPrice());
                i.putExtra("desc",recentlyViewedList.get(position).getDescription());
                i.putExtra("qty",recentlyViewedList.get(position).getQuantity());
                i.putExtra("unit",recentlyViewedList.get(position).getUnit());
 
                context.startActivity(i);
 
            }
        });
 
    }
Cannot resolve constructor 'Intent(insecte.programme.ulision.ui.home.ordre.les_hymenopteres.Hymenopteres_Un_Trois, java.lang.Class<insecte.programme.ulision.ui.home.ordre.insectes_Details>)'
 
 
    @Override
    public int getItemCount() {
        return recentlyViewedList.size();
    }
 
    public  static class RecentlyViewedViewHolder extends RecyclerView.ViewHolder{
 
        TextView name, description, price, qty, unit;
        ConstraintLayout bg;
 
        public RecentlyViewedViewHolder(@NonNull View itemView) {
            super(itemView);
 
            name = itemView.findViewById(R.id.product_name);
            description = itemView.findViewById(R.id.description);
            price = itemView.findViewById(R.id.price);
            qty = itemView.findViewById(R.id.qty);
            unit = itemView.findViewById(R.id.unit);
            bg = itemView.findViewById(R.id.recently_layout);
 
        }
    }
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
package insecte.programme.ulision.ui.home.ordre.les_hymenopteres;
 
import android.os.Bundle;
 
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
 
import java.util.ArrayList;
import java.util.List;
 
import insecte.programme.ulision.R;
import insecte.programme.ulision.ui.home.ordre.adapter.RecentlyViewedAdapter;
import insecte.programme.ulision.ui.home.ordre.model.RecentlyViewed;
 
/**
 * A simple {@link Fragment} subclass.
 */
 
public class Hymenopteres_Un_Trois extends Fragment {
 
    RecyclerView recentlyViewedRecycler;
 
 
 
    RecentlyViewedAdapter recentlyViewedAdapter;
    List<RecentlyViewed> recentlyViewedList;
    private int fragment_hymenopteres_un_trois;
 
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_hymenopteres_un_trois );
 
 
        recentlyViewedRecycler = recentlyViewedRecycler.findViewById (fragment_hymenopteres_un_trois);
 
 
 
        // adding data to model
        recentlyViewedList = new ArrayList<> ();
        recentlyViewedList.add(new RecentlyViewed("un", "Water melon water Water melon water.", "taille 80", "1000", "tordue", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("deux", "Papayas Papayas Papayas Papayas Papayas.", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("trois", "fruit , fruit , fruit , fruit.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("quatre", "Full Full Full Full Full Full Full Full.", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("cinq", "Water melon water Water melon water.", "₹ 80", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("six", "Papayas Papayas Papayas Papayas Papayas.", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("sept", "fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("huit", "Full Full Full Full Full Full Full Full.", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("neuf", "Watermelon has high water content and also provides some fiber.", "₹ 80", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("dix", "Papayas Papayas Papayas Papayas Papayas", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("onze", "Water melon water Water melon water.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("douze", "Full Full Full Full Full Full Full Full..", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("treize", "Water melon water Water melon water Water melon water Water melon water.", "₹ 80", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("quatorze", "Papayas Papayas Papayas Papayas Papayas", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("quinze", "Water melon water Water melon water.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("seize", "Full Full Full Full Full Full Full Full..", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("dix sept", "fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit , fruit .", "₹ 80", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("dix huit", "Papayas Papayas Papayas Papayas Papayas", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("dix neuf", "vitamin C ; vitamin C ; vitamin C ; vitamin C; vitamin C ; vitamin C ; vitamin C.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("vingt", "Full Full Full Full Full Full Full Full.", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("vingt un", "vitamin C ; vitamin C ; vitamin C ; vitamin C; vitamin C ; vitamin C ; vitamin C.", "₹ 80", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("vingt deux", "Papayas Papayas Papayas Papayas Papayas", "₹ 85", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("vingt trois", "vitamin C ; vitamin C ; vitamin C ; vitamin C; vitamin C ; vitamin C ; vitamin C.", "₹ 30", "1", "KG", R.drawable.b1,R.drawable.b1));
        recentlyViewedList.add(new RecentlyViewed("vingt quatre", "Full Full Full Full Full Full Full Full..", "₹ 30", "1", "PC", R.drawable.b1,R.drawable.b1));
 
 
        setRecentlyViewedRecycler(recentlyViewedList);
 
    }
 
    private void setContentView(int fragment_hymenopteres_un_trois) {
        this.fragment_hymenopteres_un_trois = fragment_hymenopteres_un_trois;
    }
 
 
    private void setRecentlyViewedRecycler(List<RecentlyViewed> recentlyViewedDataList) {
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager (this, LinearLayoutManager.VERTICAL, false);
        recentlyViewedRecycler.setLayoutManager(layoutManager);
        recentlyViewedAdapter = new RecentlyViewedAdapter(this,recentlyViewedDataList);
        recentlyViewedRecycler.setAdapter(recentlyViewedAdapter);
    }
 
}
dans celui ci aucune erreur c'est details

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
package insecte.programme.ulision.ui.home.ordre;
 
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
 
import androidx.appcompat.app.AppCompatActivity;
 
import insecte.programme.ulision.R;
import insecte.programme.ulision.ui.home.ordre.les_hymenopteres.Hymenopteres_Un_Trois;
 
public class insectes_Details extends AppCompatActivity {
 
    ImageView img, back;
    TextView proName, proPrice, proDesc, proQty, proUnit;
 
    String name, price, desc, qty, unit;
    int image;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_insectes_details );
 
        Intent i = getIntent();
 
         name = i.getStringExtra("name");
         image = i.getIntExtra("image", R.drawable.b1);
         price = i.getStringExtra("price");
         desc = i.getStringExtra("desc");
         qty = i.getStringExtra("qty");
         unit = i.getStringExtra("unit");
 
         proName = findViewById(R.id.productName);
         proDesc = findViewById(R.id.prodDesc);
         proPrice = findViewById(R.id.prodPrice);
         img = findViewById(R.id.big_image);
         back = findViewById(R.id.back2);
         proQty = findViewById(R.id.qty);
         proUnit = findViewById(R.id.unit);
 
         proName.setText(name);
         proPrice.setText(price);
         proDesc.setText(desc);
         proQty.setText(qty);
         proUnit.setText(unit);
 
 
        img.setImageResource(image);
 
 
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
 
                Intent i = new Intent( insectes_Details.this, Hymenopteres_Un_Trois.class);
                startActivity(i);
                finish();
 
            }
        });
 
    }
 
}

je sais pas si vous avez tout pour pouvoir identifier mon problème .je me suis tourné vers c'est tuto car j'avais la possibilité de supprimer ou ajouter un item