我第一次使用Butterknife,但一定是錯誤的。我有一個片段和列表視圖和一個TextView只是用於測試,但Butterknife不會綁定我的變量:Android Butterknife - 在片段中綁定
public class MyFragment extends Fragment {
@Bind(R.id.resultListView) ListView resultList;
@Bind(R.id.textView1) TextView test;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my, container, false);
ButterKnife.bind(this, view);
System.out.println(resultList); //null
System.out.println(view.findViewById(R.id.resultListView)); //works
System.out.println(test); //null
System.out.println(view.findViewById(R.id.textView1)); //works
return view;
}
}
沒有異常或任何東西。手動綁定的作品,所以我的意見必須在那裏。
什麼你的依賴是什麼樣子? –
我只有Butterknife罐子。 – breakline
啊,你用的是eclipse嗎? –