簡體   English   中英

如何在回收站視圖點擊上移動不同的活動?

[英]How to move a different activity on recycler view click?

當我單擊任何回收站視圖時,我想移動到不同的活動。 但是當我點擊其中任何一個時,它會進入相同的活動

ArrayList<FeaturedHelperClass> featuredLocations = new ArrayList<>();

featuredLocations.add(new FeaturedHelperClass(R.drawable.auditorium_a, "Mahatma Gandhi Auditorium", "It is a long established fact that a reader."));
featuredLocations.add(new FeaturedHelperClass(R.drawable.auditorium_a, "Nethaji Auditorium", "It is a long established fact that a reader."));
featuredLocations.add(new FeaturedHelperClass(R.drawable.auditorium_a, "V.O.C. Auditorium", "It is a long established fact that a reader."));
featuredLocations.add(new FeaturedHelperClass(R.drawable.audtiorium_b, "Conference Room - AB", "It is a long established fact that a reader."));
featuredLocations.add(new FeaturedHelperClass(R.drawable.audtiorium_b, "RUBY (Admin Block)", "It is a long established fact that a reader."));
featuredLocations.add(new FeaturedHelperClass(R.drawable.smart_classroom, "Smart Class", "It is a long established fact that a reader."));

adapter = new FeaturedAdapter(featuredLocations, this);
featuredRecycler.setAdapter(adapter);

Go 到適配器 class 在onBindViewHolder創建holder.view.setOnClickListener

例如:

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

    holder.itemView.setOnClickListener(view -> {

                Intent reminderActivity = new Intent(view.getContext(), CoinReminderActivity.class);
                reminderActivity.putExtra(Constants.COIN_NAME, currencies.getCoinName().toLowerCase());
                view.getContext().startActivity(reminderActivity);

    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM