GenericRecyclerAdapter icon indicating copy to clipboard operation
GenericRecyclerAdapter copied to clipboard

How to implement onclick on item?

Open JobGetabu opened this issue 5 years ago • 1 comments

JobGetabu avatar Jun 21 '19 11:06 JobGetabu

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(); }

Dennis-Mwea avatar Jun 23 '19 15:06 Dennis-Mwea