2017-12-10 9 views
0

データをフラグメント内に表示したいが、一部のメソッドはアクティビティ内のフラグメントには適用されないようです。 *の付いたテキストが私にエラーを引き起こしています。私はフラグメント上でそれをどのように実行できますか?代わりにthisフラグメントを使用してRecycleviewにMySQLデータを表示

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

getActivity().getApplication()としてみてください。

願っています。

+0

ありがとうございました。もうエラーはありませんが、私のリサイクルビューに表示される項目はありません –

+0

'Fadventure.this'ではなく' getApplicationContext() 'を試してみてください。 – Shambhu

+0

'Fadventure.this'は' fragment'を使っているあなたの現在のコンテキストですか? – Shambhu

関連する問題