Hot questions for Using Butter Knife in android recyclerview

Top 10 Java Open Source / Butter Knife / android recyclerview

Question:

  1. ButterKnife.bind(this) error
private void bindButterKnife() {

        ButterKnife.bind(this);
    }
  1. (this, new ArrayList()) and (new LinearLayoutManager(this)); error
private void setUserRecyclerView() {
    mUsersChatAdapter = new UsersChatAdapter(this, new ArrayList<User>());
    mUsersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mUsersRecyclerView.setHasFixedSize(true);
    mUsersRecyclerView.setAdapter(mUsersChatAdapter);
}

someone help me pls


Answer:

  1. override onViewCreated and use ButterKnife as ButterKnife.bind(this, view)
  2. Use getActivity() instead of this

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          ButterKnife.bind(this, view);
    }