[英]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.