小编ran*_*nys的帖子

ButterKnife为什么不能绑定私有内部类中的字段?

在一个片段中,我有一个打开PopupWindow的按钮.

private class onMenuClickListener implements View.OnClickListener {
    @BindView(R.id.popup_radiogroup) RadioGroup popupRadioGroup;
    @BindView(R.id.popup_textview) TextView popupTextView;

    PopupWindow popupWindow = getPopupWindow(R.layout.popup_window);

    @Override
    public void onClick(View v) {
        ButterKnife.bind(this, popupWindow.getContentView());
        popupWindow.showAsDropDown(menuButton);
    }
}
private PopupWindow getPopupWindow(int layout_resource_id)  {
    LayoutInflater inflater = (LayoutInflater) getContext()
            .getSystemService(LAYOUT_INFLATER_SERVICE);
    View popupView = inflater.inflate(layout_resource_id,(ViewGroup)getView());

    return new PopupWindow(popupView,
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT,true);
}
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时,我收到此错误:"@BindView字段可能不包含在私有类中." 为什么ButterKnife无法访问私有内部类,但它可以自由访问受保护的内部类?

android inner-classes private-class butterknife

9
推荐指数
1
解决办法
4651
查看次数