Ramotion/folding-cell-android

Pass info throw a listener

oscarshaitan opened this issue · 3 comments

I'm trying to pass a info contained on the item (like price) to a new activity when press the Request button, so i need get first the info using something like "items.get(i).getBoxID()" the problem is when i do
for(int i = 0; i< items.size(); i++) {
final ArrayList idboxes = new ArrayList<>();
final int finalI = i;
items.get(i).setRequestBtnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), "CUSTOM HANDLER FOR FIRST BUTTON", Toast.LENGTH_SHORT).show();
                System.out.println(items.get(i).getBoxID());
            }
        });

}

on the println there is a error with the i variable the code need to be final but that doesn't do what i need
any idea?

Solved using the listener on the item and not on the adaptor

Hey,
may you post your solution?
I am struggling with quite the same problem, I want to pass infos from current cell when pressing the button.

Thank you!

Thomas the proyec was 1 year ago and I dont remember all :/ but he solutión was quite simple, on item of each element I store the listeners.
The item have all the info, so you can use that as a guide.
the code on the first comment its de solution i found
sorry for my english