1、Activity的绑定:
ButterKnife.bind(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activtiy_battery);
ButterKnife.bind(this);
}
2、Fragment的绑定:
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.f_modify,null);
ButterKnife.bind(this,view);
initReceiver(new String[]{action_getData,action_update});
return view;
}
注意这里的this,不能改用getActivity()方法,否则会报错。
网友评论