• 4

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I am using Github library StepperTouch in my recyclerview layout. Inside my adapter, I am trying to remove an element from the array list when the stepper is zero or change the value of the element inside the array list when the value is increased or decreased. Problem is as to how to notify the adapter of the change inside my bindviewholder() method below is my adapter

public class MyCartAdapter  extends RecyclerView.Adapter<MyCartAdapter.MyCartViewHolder>{
private List<AllItems> listItems1;
private Context context;

public MyCartAdapter(List<AllItems> listItems1, Context context) {
    this.listItems1 = listItems1;
    this.context = context;

public MyCartAdapter.MyCartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View v = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.cart_items_layout, parent, false);
    return new MyCartViewHolder(v);

public void onBindViewHolder(@NonNull final MyCartAdapter.MyCartViewHolder holder, final int position) {

    final AllItems orderItem = listItems1.get(position);
    String price = String.valueOf(orderItem.getPrice());

    final HashMap<String, AllItems> items = ((UserMainActivity)context).getItemMap();

    holder.stepperTouch.addStepCallback(new OnStepCallback() {
        public void onStep(int value, boolean positive) {
            int count = holder.stepperTouch.getCount();
            if (count==0){
                AllItems item = items.get(orderItem.getName());
                if (item!=null){
                    String orderit = orderItem.getName();
            else {
                    String quantity = String.valueOf(holder.stepperTouch.getCount());
                    String orderitemname = orderItem.getName();
                    String url = orderItem.getImageUrl();
                    String weight = orderItem.getWeight();
                    AllItems newitem = new AllItems(orderitemname ,orderItem.getComname(),url, quantity,weight,orderItem.getPrice());
                    listItems1.set(position, newitem);

public int getItemCount() {

    return listItems1.size();


public class MyCartViewHolder extends RecyclerView.ViewHolder {
    public TextView name,price,count,comname;
    public TextView weight;
    public ImageView productImage;

    public MyCartViewHolder(View itemView) {
        name = (TextView) itemView.findViewById(R.id.ProName);
        price = (TextView) itemView.findViewById(R.id.proPrice);
        weight = (TextView) itemView.findViewById(R.id.ProWeight);

    public void setProductImage(final String thumb_image, final Context ctx){

        productImage = (ImageView) itemView.findViewById(R.id.ProImage);
                .placeholder(R.drawable.basket_b).into(productImage, new Callback() {
            public void onSuccess() {
            public void onError() {

    public void setComname(String name){
        comname = (TextView)itemView.findViewById(R.id.proComName);
    public void setStepper(final Context context){
        stepperTouch = (StepperTouch) itemView.findViewById(R.id.stepper);
    StepperTouch stepperTouch;


i have tried using MyCartAdapter.this.notifyDataSetChanged(); but its showing error. Cannot call this method while RecyclerView is computing a layout or scrolling androidx.recyclerview.widget.RecyclerView

the above code works for removing but I can not do the notifyDatasetChanged() inside the bindview method is there any way to use notifydatasetChanged() in this case.

try running it on UI thread

 runOnUiThread(new Runnable(){
  public void run() {
  // UI code goes here
  • 1
Reply Report
    • did you tried notify data if not please call notifyDataSetChanged() after this line listItems1.remove(position)
    • yes i have tried after remove() method but its showing an error cannot call this method while RecyclerView is computing a layout or scrolling androidx.recyclerview.widget.RecyclerView

You are not in the scope of your Adapter, but rather of your OnStepCallback. To access your adapter's scope you can try : YourAdapter.this.notifyDataSetChanged();

  • 0
Reply Report