Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass info throw a listener #41

Closed
oscarshaitan opened this issue Mar 3, 2017 · 3 comments
Closed

Pass info throw a listener #41

oscarshaitan opened this issue Mar 3, 2017 · 3 comments

Comments

@oscarshaitan
Copy link

oscarshaitan commented Mar 3, 2017

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?

@oscarshaitan
Copy link
Author

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

@ThomasKoscheck
Copy link

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!

@oscarshaitan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants