我已成功将 findViewByIds
替换为 Butterknife 库。
不幸的是,出现了一个问题:
final Button btnPopup = (Button) popupView.findViewById(R.id.btn_popup); //popupView.findViewById(...) problem!!!
如何在 Butterknife 中更改这行代码:因为 Butterknife.bind(this);
占用了整个 Activity Views
最佳答案
使用
将您的 popupView 绑定(bind)到您的主视图View popupView = View.inflate(getContext(), R.layout.yourPopup, null);
ButterKnife.bind(this,popupView);
或者你可能想直接使用
Button btnPopup = ButterKnife.findById(popupView, R.id.btn_popup);
关于Android - 用 Butterknife 替换 findViewById,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45879342/