2
bindView我有這樣的情況:Butterknife如何從我的項目不同的意見
@BindView(R.id.viewpager)
ViewPager viewPager;
TabLayout tabLayout;
AddParkingFragmentListener listener;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.fragment_add_parking, container, false);
ButterKnife.bind(this, inflatedView);
tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs);
tabLayout.setVisibility(View.VISIBLE);
return inflatedView;
}
,我需要綁定一個觀點,即在activity_main.xml
佈局。 我以爲我可以使用一個接口直接在MainActivity中禁用可見性,但我也知道是否有可能使用Butterknife綁定這個視圖,因爲在MainActivity中我也有這個問題:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View view = navigationView.getHeaderView(0);
profile = (ImageView) view.findViewById(R.id.imgPro);
//this views are in the navigation view, how to bind using butterknife?
logo = (ImageView) view.findViewById(R.id.logo);
email = (TextView) findViewById(R.id.email_profile);
ButterKnife.bind(this);
}
有沒有辦法做到這一點,或者我需要使用findViewById()方法?
感謝
所以我可以使用經典@BindView爲他人的正常意見和ButterKnife.findById? – ste9206
是:D就是這樣! –
太好了:D非常感謝你! – ste9206