@Override
public void onBindViewHolder(@NonNull ImageViewHolder holder, @SuppressLint("RecyclerView") int position) {
holder.imageView.setImageResource(imageList.get(position));
if(position == imageList.size() - 2){
viewPager2.post(runnable);
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(view.getContext(), "You clicked on : " + position, Toast.LENGTH_SHORT).show();
if(position == 0){
Toast.makeText(viewPager2.getContext(), "Welcome", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(view.getContext(), Activity_2.class);
view.startActionMode((ActionMode.Callback) intent);
// startActivity(intent) , this class needs to be created it says
}
}
});
}
Toasts addressed are shown but the intent in the same activity is not practised on the same position….the method of startActivity(intent) is also not recognised….please help
2
Answers
Pass your activity to view pager adapter.
activity.startActivity(new Intent(activity,DestnationActivity,.class));
activity = variable name for hold your activity
Try With This Code