Butter Knife @bind in Fragment错误

我按照网站上的说明操作: http : //jakewharton.github.io/butterknife/

error:java.lang.RuntimeException:无法启动活动ComponentInfo。 java.lang.RuntimeException:无法绑定com.project.myapp.OneFragment的视图。

我尝试删除@Bind(R.id.btnNext) Button btnNext; 并且没有运行错误。

 public class OneFragment extends Fragment { @Bind(R.id.btnNext) Button btnNext; private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1; private String mParam2; private OnFragmentInteractionListener mListener; public OneFragment() { // Required empty public constructor } public static OneFragment newInstance(String param1, String param2) { OneFragment fragment = new OneFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_one, container, false); ButterKnife.bind(this, view); return view; } public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); } } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnFragmentInteractionListener) { mListener = (OnFragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } public interface OnFragmentInteractionListener { void onFragmentInteraction(Uri uri); } } 

替换这个:

 ButterKnife.bind(this, view); 

 ButterKnife.bind(getActivity(), view);