使用片段在Recycleview中显示MySQL数据

时间:2017-12-10 11:57:12

标签: android

我想在片段中显示我的数据,但似乎某些方法不适用于仅在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;
}

1 个答案:

答案 0 :(得分:0)

代替this尝试使用getActivity().getApplication()

希望它有所帮助。