RecyclerView with Clickable按钮

时间:2015-08-15 14:00:46

标签: android button android-recyclerview recycler-adapter android-parsequeryadapter

所以我正在使用从ParseQuery Adapter获取数据的recyclerview适配器。 无论如何,现在的问题是,在每个项目或行中我都有一个按钮。喜欢投票按钮。

每次点击一个按钮,它会自动在其他行的其他按钮上随机点击

知道问题是什么吗?

这是我的代码。

YOUR_TABLE.reloadSections(NSIndexSet(index: 0), withRowAnimation: UITableViewRowAnimation.Automatic) // You can try different UITableViewRowAnimations to see what you like

1 个答案:

答案 0 :(得分:0)

从顶部删除Button声明并在此处声明:

final Button voteUp =(Button)v.findViewById(R.id.like);

当您将Button声明为顶部的全局变量时,它不会为gridview或listview的每一行正确分配变量。

需要在此处指定,因此按钮的每次迭代都使用单独的onclick监听器进行设置。