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

How to implement onclick on item? #6

Open
JobGetabu opened this issue Jun 21, 2019 · 1 comment
Open

How to implement onclick on item? #6

JobGetabu opened this issue Jun 21, 2019 · 1 comment

Comments

@JobGetabu
Copy link

No description provided.

@Dennis-Mwea
Copy link

Dennis-Mwea commented Jun 23, 2019

Use greenbot eventbus.
implementation 'org.greenrobot:eventbus:3.0.0'
Then in your view holder bindData()
SingleItemRootLayout rootLayout = view.findViewById(R.id.contact_row); rootLayout.setOnClickListener(v -> EventBus.getDefault().post(Model));

In your activity onCreate() just have
Eventbus.getDefault().register(this)

then create a private method in your activity to handle the onclick event
@Subscribe(threadMode = ThreadMode.MAIN) public fun onRowClicked(pModel: OrderModel) { Toast.makeText(this, "Name: " + pModel.id + " Surname: " + pModel.createdAt, Toast.LENGTH_SHORT).show(); }

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