问题描述
- 将基于activity的代码移植到基于fragment的页面中
-
private void initView() {expandTabView = (ExpandTabView) findViewById(R.id.expandtab_view); viewLeft = new LeftFilterView(this, FilterDataSource.createPriceFilterItems()); viewMiddle = new MiddleFilterView(this); viewRight = new RightFilterView(this, FilterDataSource.createSortFilterItems()); }
上方代码要是移植到fragment页面中需要修改什么?
我改成了这样,但是运行时调用view的时候出现了空指针
private void initView() {expandTabView = (ExpandTabView) getActivity().findViewById(R.id.expandtab_view); viewLeft = new LeftFilterView(getActivity(), FilterDataSource.createPriceFilterItems()); viewMiddle = new MiddleFilterView(getActivity()); viewRight = new RightFilterView(getActivity(), FilterDataSource.createSortFilterItems()); }
时间: 2024-10-03 05:14:38