我想在片段中显示我的数据,但似乎某些方法不适用于仅在Activity中的片段。带*的文字导致我出错。我如何在片段上执行它?
String urlAddress = "http://capstonproject.xyz/project/tourist/retrieve/adventure";
RecyclerView recyclerView;
public Fadventure() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
//RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_fadventure, container, false);
return inflater.inflate(R.layout.fragment_fadventure, container, false);
recyclerView = view.findViewById(R.id.adventure_list);
recyclerView.setLayoutManager(new LinearLayoutManager(***this***));
recyclerView.setItemAnimator(new DefaultItemAnimator());
new DBFetch(***Fadventure.this***,recyclerView).execute();
//return recyclerView;
}
答案 0 :(得分:0)
代替this
尝试使用getActivity().getApplication()
。