I have two RecylerView one is inside other. Now I want to update my inner recyclerView item on click of an item. So after updating my local database I am calling notifyDataSetChanged(), but this is not calling my onBindViewHolder() again.
Below is my code for onItemClick():
public class MyViewHolder extends RecyclerView.ViewHolder {
private ImageView imageView;
private TextView tvTutorialName, text_new;
private ConstraintLayout main_item;
public MyViewHolder(#NonNull View itemView) {
super(itemView);
main_item = itemView.findViewById(R.id.main_item);
tvTutorialName = itemView.findViewById(R.id.tutorial_name);
text_new = itemView.findViewById(R.id.text_new);
imageView = itemView.findViewById(R.id.tutorial_image);
main_item.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
manager.save("tutorialTapGuide", "notFirstTime");
TutorialViewModel tutorialViewModel = new TutorialViewModel(SmartMirror.getInstance());
int pos = (int) view.getTag();
tutorialName = mVideoList.get(pos).serverFolderName;
tutorialId = mVideoList.get(pos).objectId;
// update
tutorialViewModel.updateNewTutorialToOld(tutorialName);
notifyDataSetChanged();
// allCheckingAfterStoragePermissionGranted(view.findViewById(R.id.tutorial_image), pos);
}
});
}
#Override
public void onBindViewHolder(#NonNull MyViewHolder myViewHolder, int position) {
myViewHolder.main_item.setTag(position);
String tutorialFolder = mVideoList.get(position).serverFolderName;
myViewHolder.tvTutorialName.setText(mVideoList.get(position).displayTutorialName);
myViewHolder.main_item.setTransitionName("trans_image" + position);
TutorialViewModel tutorialViewModel = new TutorialViewModel(SmartMirror.getInstance());
int isNewTutorial = tutorialViewModel.isNewTutorial(tutorialFolder);
if (isNewTutorial == 1)
myViewHolder.text_new.setVisibility(View.VISIBLE);
if (CommonUtilities.haveNetworkConnection(mContext)) {
Glide.with(mContext).load(mVideoList.get(position).imageURL)
.apply(new RequestOptions().placeholder(R.drawable.video_placeholder).error(R.drawable.video_placeholder))
.into(myViewHolder.imageView);
} else {
myViewHolder.imageView.setImageResource(R.drawable.video_placeholder);
}
}
I am setting the adapter of child recyclerView from parent recyclerView adapter.
holder.mAdapter = new TutorialVideoAdapter(mctx, mFrg, mTracker, videosArrayList, parentView, parent_fragment, catList.get(position), tutorialStepsList, player, holder.recyclerView_tutorial);
holder.recyclerView_tutorial.setLayoutManager(new GridLayoutManager(mctx, 3));
holder.recyclerView_tutorial.setAdapter(holder.mAdapter);
holder.recyclerView_tutorial.setScrollY(00);
I am now clueless why notifyDataSetChanged() not triggering onBindViewHolder.
Related
I want to hide checkbox of all lists if I clicked one list within activity using recyclerview.
But when I implement it, only the check box in the recyclerview list of the clicked position disappears. How can I hide the checkbox of the entire list?
Of course it is possible on the reyclerview adapter, but I want this function to be implemented in activity.
In activity, the adapter was declared:
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerViewAdapter = new RecyclerViewAdapter(this, patientList, selected_patientList);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(recyclerViewAdapter);
And I wrote the code that hides the check box when click the recyclerview list in activity :
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, recyclerView, new RecyclerItemClickListener.OnItemClickListener() {
#Override
public void onItemClick(View view, int position) {
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkBox) ;
checkBox.setVisibility(View.GONE);
}
And my recyclerview adapter code is
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> {
private Activity activity;
public ArrayList<PatientItem> patientList = new ArrayList<>();
public ArrayList<PatientItem> selected_patientList = new ArrayList<>();
Context mContext;
boolean checkboxIsVisible = true ;
public RecyclerViewAdapter(Context context, ArrayList<PatientItem> patientList, ArrayList<PatientItem> selected_patientList) {
this.mContext = context;
this.patientList = patientList;
this.selected_patientList = selected_patientList;
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView patientType;
TextView clinicID;
TextView patientName;
TextView dateFirst;
TextView dateFinal;
CheckBox checkBox ;
ConstraintLayout cl_listitem;
public MyViewHolder(View itemView) {
super(itemView);
patientType = (TextView) itemView.findViewById(R.id.typeViewItem);
clinicID = (TextView) itemView.findViewById(R.id.clinicIDItem);
patientName = (TextView) itemView.findViewById(R.id.patientNameItem);
dateFirst = (TextView) itemView.findViewById(R.id.dateFirstItem);
dateFinal = (TextView) itemView.findViewById(R.id.dateFinalItem);
checkBox = (CheckBox) itemView.findViewById(R.id.checkBox) ;
cl_listitem = (ConstraintLayout) itemView.findViewById(R.id.cl_listitem);
}
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.patient_list_item, parent, false);
final RecyclerViewAdapter.MyViewHolder vHolder = new RecyclerViewAdapter.MyViewHolder(itemView) ;
return vHolder;
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
PatientItem data = patientList.get(position);
holder.patientType.setText(data.getPatientType());
holder.clinicID.setText(data.getClinicID());
holder.patientName.setText(data.getPatientName());
holder.dateFirst.setText(data.getDateFirst());
holder.dateFinal.setText(data.getDateFinal());
holder.checkBox.setChecked(data.isDeleteBox());
holder.checkBox.setVisibility(checkboxIsVisible?View.VISIBLE:View.GONE);
if(data.getPatientType() == "P"){
holder.patientType.setText("");
holder.patientType.setBackground(ContextCompat.getDrawable(mContext, R.drawable.parkinson));
}
else if(data.getPatientType() == "ET"){
holder.patientType.setText("");
holder.patientType.setBackground(ContextCompat.getDrawable(mContext, R.drawable.essential_tremor));
}
else{
holder.patientType.setText("ㅡ");
}
}
#Override
public int getItemCount() {
return patientList.size();
}
public void clear() {
int size = patientList.size() ;
patientList.clear() ;
notifyItemRangeRemoved(0, size);
}
//어댑터 정비
public void refreshAdapter() {
this.selected_patientList = selected_patientList;
this.patientList = patientList;
this.notifyDataSetChanged();
}
}
I solved this problem like this.
I declared onBindViewHolder at RecyclerViewAdapter:
holder.checkBox.setVisibility(checkboxIsVisible?View.VISIBLE:View.GONE);
And, I declared visible() method in RecyclerViewAdapter :
public void visible(){
checkboxIsVisible = false ;
this.notifyDataSetChanged();
}
Than, I use visible method in activity :
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, recyclerView, new RecyclerItemClickListener.OnItemClickListener() {
#Override
public void onItemClick(View view, int position) {
recyclerViewAdapter.visible();
}
When I run this, when I click on one list, all the check boxes on the list disappear.
i have a recyclerview in my activity and in each item i have two button and a ordernumber when minus bottom make zero the ordernumber, i want to hide this item and other item come up and fill the blank space.I hide the item with setVisibility() but i don`t know how to handle blank space.
this is my recyclerview adapter:
package com.test.mohammaddvi.snappfood.Adapter;
public class RecyclerViewBuyBasketAdapter extends RecyclerView.Adapter<RecyclerViewBuyBasketAdapter.SingleItemBuyBasket> {
private ArrayList<FinalFood> foodList;
private Context mContext;
private View view;
public RecyclerViewBuyBasketAdapter(ArrayList<FinalFood> foodList, Context mContext) {
this.foodList = foodList;
this.mContext = mContext;
}
#NonNull
#Override
public RecyclerViewBuyBasketAdapter.SingleItemBuyBasket onCreateViewHolder(ViewGroup parent, int viewType) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.buybasketitem, null);
return new RecyclerViewBuyBasketAdapter.SingleItemBuyBasket(view);
}
#Override
public void onBindViewHolder(final RecyclerViewBuyBasketAdapter.SingleItemBuyBasket holder, int position) {
FinalFood food = foodList.get(position);
holder.foodName.setText(food.getName());
holder.foodDetails.setText(food.getDetails());
holder.foodPrice.setText(food.getPrice());
holder.foodOrderNumber.setText(food.getOrdernumber() + "");
handleClick(holder, view);
}
private void handleClick(final RecyclerViewBuyBasketAdapter.SingleItemBuyBasket holder, final View view) {
holder.foodPlusButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
FinalFood food = foodList.get(holder.getAdapterPosition());
int orderNumber = food.getOrdernumber();
int newOrderNumber = orderNumber + 1;
food.setOrdernumber(newOrderNumber);
holder.foodOrderNumber.setText(newOrderNumber + "");
}
});
holder.foodMinusButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
FinalFood food = foodList.get(holder.getAdapterPosition());
int orderNumber = food.getOrdernumber();
if (orderNumber == 1) {
int newOrderNumber = orderNumber - 1;
food.setOrdernumber(newOrderNumber);
view.setVisibility(View.GONE);
} else {
int newOrderNumber = orderNumber - 1;
food.setOrdernumber(newOrderNumber);
holder.foodOrderNumber.setText(newOrderNumber + "");
}
}
});
}
#Override
public int getItemCount() {
return (null != foodList ? foodList.size() : 0);
}
public class SingleItemBuyBasket extends RecyclerView.ViewHolder {
TextView foodName;
TextView foodPrice;
Button foodPlusButton;
Button foodMinusButton;
TextView foodOrderNumber;
TextView foodDetails;
SingleItemBuyBasket(View itemView) {
super(itemView);
this.foodName = itemView.findViewById(R.id.foodNameInBuyBasket);
this.foodPrice = itemView.findViewById(R.id.foodPriceInBuyBasket);
this.foodDetails = itemView.findViewById(R.id.foodDetailsInBuyBasket);
this.foodPlusButton = itemView.findViewById(R.id.plusbuttonInBuyBasket);
this.foodMinusButton = itemView.findViewById(R.id.minusbuttonInBuyBasket);
this.foodOrderNumber = itemView.findViewById(R.id.ordernumberInBuyBasket);
}
}
}
and this is my activity:
package com.test.mohammaddvi.snappfood;
public class BuyBasket extends AppCompatActivity{
ArrayList<FinalFood> foods = new ArrayList<>();
RecyclerViewBuyBasketAdapter recyclerViewBuyBasketAdapter;
RecyclerView recyclerView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buy_basket);
recyclerView = findViewById(R.id.recyclerview);
foods= (ArrayList<FinalFood>) getIntent().getSerializableExtra("final");
recyclerViewBuyBasketAdapter = new RecyclerViewBuyBasketAdapter(foods, BuyBasket.this);
recyclerView.setLayoutManager(new LinearLayoutManager(BuyBasket.this, LinearLayoutManager.VERTICAL, false));
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(recyclerViewBuyBasketAdapter);
}
}
It's better you delete the entire row rather than changing visibility. This is the code to remove the row. You need to call removeItem(position); method in your button onclickListener
public void removeItem(int position)
{
// Remove specified position
models.remove(position);
// Notify adapter to remove the position
notifyItemRemoved(position);
// Notify adapter about data changed
notifyItemChanged(position);
// Notify adapter about item range changed
notifyItemRangeChanged(position, arraylist.size());
}
Inside your xml, define two parents. One for the hidden content and the other for the item that you want to appear when you hide the first one
Try playing with View when clicking in one parent or the other:
layout.setVisibility(View.GONE) or view.setVisibility(View.VISIBLE);
The title seems confusing because I cannot explain this properly using text.
I'll try my best to explain my problem.
Currently I have items in my recyclerview :
Each item contains a delete button that will remove the item in the recyclerview.
Lets assume that I have 5 items in the list:
what I want to attain is when the user deletes
Item 2
the information/data from item 3 will be transferred to Item 2,
the data from item 4 will be transferred to item 3 and
the data from item 5 will be transferred to item 4
and lastly the item 5 will be deleted.
I currently have no code for this but I'm trying my best to construct it.
Here is my adapter code, it might help:
public class CreditCard_PostPayAdapter extends RecyclerView.Adapter<CreditCard_PostPayAdapter.MyViewHolder> {
private static String TAGedittext = "";
//private final AccountHistoryTransactionActivity homeActivity;
private Context mContext;
private ArrayList<Integer> mHeaderText;
CreditCard_PostPayAdapter adapter;
public CreditCard_PostPayAdapter(Context mContext, ArrayList<Integer> mHeaderTextList ) {
this.mContext = mContext;
this.mHeaderText = mHeaderTextList;
}
#Override
public CreditCard_PostPayAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.creditcard_postpay_item, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(final CreditCard_PostPayAdapter.MyViewHolder holder, int position) {
final int pos = position + 1;
final int mPosition = position;
if (mHeaderText.size() == 1) {
holder.mDeleteButton.setVisibility(View.GONE);
} else {
holder.mDeleteButton.setVisibility(View.VISIBLE); }
holder.mDeleteButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
mHeaderText.remove(mPosition);
ArrayList<Integer> temp = new ArrayList<Integer>();
for (int i = 0 ; mHeaderText.size() - 1 >= i ; i++) {
temp.add(i);
Log.d("Counter++",""+i);
}
holder.mMerchantName.setText("");
holder.mTransactionAmountEditText.setText("");
holder.mTransactionDateEditText.setText("");
holder.mPostingDateEditText.setText("");
mHeaderText.clear();
mHeaderText.addAll(temp);
notifyDataSetChanged();
}
});
}
#Override
public int getItemCount() {
return mHeaderText.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView mHeaderTitle
public ImageView mArrowHeader;
public ImageButton mDeleteButton;
public TextInputEditText mTransactionDateEditText,
mPostingDateEditText,
mTransactionAmountEditText;
public MyViewHolder(View view) {
super(view);
this.mHeaderTitle = (TextView) view.findViewById(R.id.header_title);
this.mDeleteButton = view.findViewById(R.id.mDeleteButton);
this.mMerchantName = view.findViewById(R.id.mMerchantNameTextView);
this.mTransactionDateEditText = view.findViewById(R.id.Transaction_date);
this.mPostingDateEditText = view.findViewById(R.id.posting_date);
this.mTransactionAmountEditText = view.findViewById(R.id.Transaction_amount);
}
}
}
My current delete button function is to:
Delete the item(n) and recount all of the remaining item.
Replace your onBindViewHolder method and try,
#Override
public void onBindViewHolder(final CreditCard_PostPayAdapter.MyViewHolder holder, int position) {
holder.mDeleteButton.setTag(position);
holder.mDeleteButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
int clickedPos = (int) view.getTag();
mHeaderText.remove(clickedPos);
notifyItemRemoved(position);
}
});
}
If you want to delete the 2nd element. delete the element and remaining will be taken care by recyclerAdapter to remove the row and align the data.
inside your onClickListener, remove the data from ArrayList and the call notifyItemRemoved()
write your onClick inside ViewHolder class
onClick(View view){
mHeaderText.remove(getAdapterPosition());
notifyItemRemoved(getAdapterPosition());
}
i hope this will help you..
you an delete the item in list and refresh your adapter by just doing this in your onClick:
holder.mDeleteButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
mHeaderText.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, mHeaderText.size());
}
});
I am getting data from server and then parsing it and storing it in a List. I am using this list for the RecyclerView's adapter. I am using Fragments.
I extended
RecyclerView.Adapter<RecyclerView.ViewHolder>
this my complete adapter class
public class GridAdapter extends RecyclerView.Adapter<GridAdapter.ViewHolder> {
private List<ProductModel> list;
ItemClickListener itemClickListener;
public GridAdapter(List<ProductModel> list, ItemClickListener itemClickListener) {
this.list = list;
this.itemClickListener = itemClickListener;
}
public void update(int position,ProductModel pm){
Log.v("update adapter",position+"");
list.set(position,pm);
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.grid_item, parent, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
final ProductModel cp = list.get(position);
holder.tvName.setText(cp.name);
holder.tvPrice.setText(cp.price);
holder.ratingBar.setRating(cp.rate);
Log.v("grid",cp.id + "=="+ cp.checked);
if(cp.checked==1){
holder.imgCheck.setVisibility(View.VISIBLE);
}else{
holder.imgCheck.setVisibility(View.GONE);
}
LayerDrawable stars = (LayerDrawable) holder.ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
holder.lnrItem.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
itemClickListener.onItemClick(cp,position);
}
});
}
#Override
public int getItemCount() {
return list.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView tvName, tvPrice;
ImageView imgMenu, imgCheck;
LinearLayout lnrItem;
RatingBar ratingBar;
public ViewHolder(View itemView) {
super(itemView);
lnrItem = itemView.findViewById(R.id.lnrItem);
imgMenu = itemView.findViewById(R.id.imgMenu);
imgCheck = itemView.findViewById(R.id.imgCheck);
tvName = itemView.findViewById(R.id.tvName);
ratingBar = itemView.findViewById(R.id.ratingBar);
tvPrice = itemView.findViewById(R.id.tvPrice);
}
}
}
and in fragment activity i use this code to load adapter to recyclerview
public void fillListProduct(List<ProductModel> mItems) { //method for load adapter for the first time
mAdapterGrid = new GridAdapter(mItems,this);
recGrid.setAdapter(mAdapterGrid);
}
void update(){ //method to change checked value
mAdapterGrid.update(cp.row,cp);
mAdapterGrid.notifyDataSetChanged();
}
in my custom adapter i have 3 variable lets call id, name, checked, everything work properly, in first load i set 0 as default value for checked, in my scenario user can change checked value by tap the row of recycleview.
my question is, when user tap desire row then checked will change from 0 to 1 and display it to recycelview, i already use notifydatasetchange() but not working.
Please help.
thanks
Try to remove mAdapterGrid.notifyDataSetChanged();
and modify this function in your adpater:
public void update(int position,ProductModel pm){
Log.v("update adapter",position+"");
list.set(position,pm);
notifyItemChanged(position);
}
I have a recycler view, which consists of list. The items in the list have their own details like this (each item will have image, id, name, description), and the items are shuffeled, not in order.
Example : recyclerview item position = 0, list item id= 7.
recyclerview item position = 1, list item id= 5.
recyclerview item position = 2, list item id= 12.
So i need to get the list item id on recycler on click. If i click on recyclerview position = 0, If i have to get the item id as 7. So that i can work on that furthur based on that id.
My example code is
recommendedrecyclerView=(RecyclerView)view.findViewById(R.id.recommended_recycler_view);
recommendedrecyclerView.setNestedScrollingEnabled(false);
recommendedrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),OrientationHelper.VERTICAL,true));
recommendedrecyclerView.setItemAnimator(new DefaultItemAnimator());
I am getting data from server and setting it to adapter
setrecommendedAppsContent(response.body().getData());
public void setrecommendedAppsContent(List<FeaturedAppsData> data){
if (data!=null&&data.size()>0) {
recommendedAdapter = new RecommendedAdapter(mCurrentContext, data);
recommendedrecyclerView.setAdapter(recommendedAdapter);
recommendedAdapter.setClickListener(this);
}
}
This is my adapter class
public class RecommendedAdapter extends RecyclerView.Adapter<RecommendedAdapter.ItemViewHolder> {
private LayoutInflater inflater = null;
private Context context;
private List<FeaturedAppsData> itemsData;
private ClickListener clicklistener = null;
public TextView recommendedAppTitle,recommendedAppCategory,recommendedAppDescription;
public ImageView recommendedAppIcon;
Button recommendedBtn;
String appId;
public void setClickListener(ClickListener clickListener) {
this.clicklistener = clickListener;
}
public RecommendedAdapter(Context context, List<FeaturedAppsData> itemsData) {
this.context = context;
this.itemsData = itemsData;
}
#Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
holder.recommendedAppTitle.setText(itemsData.get(position).getName());
holder.recommendedAppCategory.setText(itemsData.get(position).getApp_description());
holder.recommendedAppDescription.setText(itemsData.get(position).getOffer_description());
holder.recommendedAppBtn.setText(itemsData.get(position).getButton_text());
String imageUrl = String.valueOf(itemsData.get(position).getImage().getUrl());
Glide.with(context).load(ApiConstant.ApiBaseUrl + imageUrl).into(recommendedAppIcon);
appId=itemsData.get(position).getId();
}
#Override
public int getItemCount() {
int size = 0;
if (itemsData != null && itemsData.size() > 0) {
size = itemsData.size();
}
return size;
}
public class ItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView recommendedAppTitle,recommendedAppCategory,recommendedAppDescription,offerDescription,offerDetailDescription,rewardDetail;
public ImageView recommendedAppIcon;
public Button recommendedAppBtn;
public ArrayList<FeaturedAppsData> dataItems;
private Context context;
public ItemViewHolder(Context context, View itemView, int viewType) {
super(itemView);
this.context = context;
itemView.setOnClickListener(this);
recommendedAppTitle = (TextView) itemView.findViewById(R.id.recommended_app_title);
recommendedAppCategory = (TextView) itemView.findViewById(R.id.recommended_app_category);
recommendedAppDescription = (TextView) itemView.findViewById(R.id.recommended_app_description);
recommendedAppIcon = (ImageView) itemView.findViewById(R.id.recommended_app_icon);
recommendedAppBtn=(Button)itemView.findViewById(R.id.recommended_app_card_btn);
}
#Override
public void onClick(View v) {
if (clicklistener != null) {
clicklistener.itemClicked(v, getAdapterPosition());
}
}
}
#Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
inflater = LayoutInflater.from(context);
view = inflater.inflate(R.layout.recommended_item_layout, parent, false);
recommendedAppIcon=(ImageView)view.findViewById(R.id.recommended_app_icon);
return new ItemViewHolder(context, view, viewType);
}
}
I am not sure of the Onclick method. So please suggest me as required along with Onclick event.
The setOnClickListener inside the ViewHolder is a good way.
Considering your current solution, the easiest way is to change the ClickListener interface, put the data inside the Holder during onBindViewHolder and then pass it to the listener during onClick. Like this:
Change the view holder fields to:
public class ItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView recommendedAppTitle,recommendedAppCategory,recommendedAppDescription,offerDescription,offerDetailDescription,rewardDetail;
public ImageView recommendedAppIcon;
public Button recommendedAppBtn;
public FeaturedAppsData data; // <<< ADD THIS
// remove that u don't need public ArrayList<FeaturedAppsData> dataItems;
// remove that u don't need private Context context;
... the rest of your holder
then inside onBindViewHolder
#Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
holder.data = itemsData.get(position);
... the rest on bind
then inside onClick, inside the holder:
#Override
public void onClick(View v) {
if (clicklistener != null) {
clicklistener.itemClicked(v, data.getId());
}
}