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 set Adapter onItemClick event it please? #5

Closed
CodeK1988 opened this issue Aug 12, 2016 · 1 comment
Closed

How to set Adapter onItemClick event it please? #5

CodeK1988 opened this issue Aug 12, 2016 · 1 comment

Comments

@CodeK1988
Copy link

I follow you.And thanks a lot. You open my eyes. but how to set Adapter onItemClick event it ?please 。 like this?
rxDataSource.repeat(1).
bindRecyclerView(fragmentBinding.mGridView, R.layout.item_homepage_gridview)
.subscribe(viewHolder -> {
RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(ViewGroup
.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
ItemHomepageGridviewBinding dataBinding = viewHolder.getViewDataBinding();
param.width=screenWidth/3;
param.height = screenWidth/5;
dataBinding.gridviewRoot.setLayoutParams(param);
long itemId = viewHolder.getItemId();
String item = viewHolder.getItem();
if(itemId < lastCount){
Picasso.with(getActivity()).load(item).into(dataBinding.gridviewNetImage);
}else{
dataBinding.gridviewNetImage.setImageResource(R.drawable.gridview_background);
}
dataBinding.getRoot().setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {

                    }
                });
            });
@ahmedrizwan
Copy link
Owner

Yes @yizuochengchi that's the right way to set onClickListener... You can also use Databinding's Binding Adapters... Which I think would be a better approach...
I'll share an example of that here, in a little while...

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