Android Butterknife - binding in fragment

前端 未结 3 1088
孤独总比滥情好
孤独总比滥情好 2021-02-11 12:45

I\'m using Butterknife for the first time but something must be wrong. I have a fragment and a Listview and a TextView just for testing but Butterknife wont bind my variables:

3条回答
  •  孤城傲影
    2021-02-11 12:55

    also dont forget to release when you are finish :

     private Unbinder unbinder;
    

    ...

     @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.finalisation_step_fragment, container, false);
            unbinder = ButterKnife.bind(this, v);
            //initialize your UI
    
            return v;
        }
    

    ...

       @Override public void onDestroyView() {
            super.onDestroyView();
            unbinder.unbind();
        }
    

提交回复
热议问题