Android butterknife无法将视图绑定到ViewHolder

时间:2016-06-12 06:06:45

标签: android

在<{1}}适配器中的

我在布局中有一些视图,我想将它与recyclerview库绑定,但我得到了

butterknife
运行应用程序时出现

错误

我的适配器:

java.lang.RuntimeException: 
Unable to bind views for ir.pishguy.signalpresentationproject.Adapters.ViewHolders.
StoreListsViewHolder
at butterknife.ButterKnife.bind

和我的public class StoreListsAdapter extends RecyclerView.Adapter<StoreListsViewHolder> { OnCardClickListner onCardClickListner; List<StoreLists> list = Collections.emptyList(); Context context; public StoreListsAdapter(List<StoreLists> list, Context context) { this.list = list; this.context = context; } @Override public StoreListsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.store_item_fields, parent, false); StoreListsViewHolder holder = new StoreListsViewHolder(v); return holder; } @Override public void onBindViewHolder(StoreListsViewHolder holder, final int position) { holder.store_title.setText(list.get(position).getStoreTitle()); } @Override public int getItemCount() { return list.size(); } @Override public void onAttachedToRecyclerView(RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); } } 班级:

ViewHolder

1 个答案:

答案 0 :(得分:0)

检查R.id.XXX中的所有store_item_fields.xml是否在您的布局(viewHolder)中通过异常错过了。您的ViewHolder类似乎没问题。

另外,为了更快地找到问题,我建议清空from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput class AddressApp(App): def build(self): pass if __name__ == '__main__': AddressApp().run() (不应该通过任何例外),然后逐个添加字段。

还尝试使用新版本的ButterKnife 8.0.1;