2 回答
TA贡献1839条经验 获得超15个赞
尝试将 空设置为adapterrecyclerViewonCreateView()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_redirect, container, false);
recylcerView =(RecyclerView) v.findViewById(R.id.recyclerView);
LinearLayoutManager manager = new LinearLayoutManager(getContext());
recylcerView.setLayoutManager(manager);
recylcerView.setHasFixedSize(true);
searchList = new ArrayList<>();
List<Search> searchList = new ArrayList<>()
SearchAdapter adapter1 = new SearchAdapter(getContext(),searchList);
recylcerView.setAdapter(adapter1);
loadSearch();
return v;
}
然后在您向呼叫中添加新项时作为响应searchListadapter1.notifyDataSetChanged()
TA贡献1830条经验 获得超3个赞
尝试更改
public class redirectFragment <recyclerView> extends Fragment
进入这个
public class redirectFragment extends Fragment
添加回答
举报