Java 我无法在类片段中使用arraylist

Java 我无法在类片段中使用arraylist,java,android,android-fragments,arraylist,Java,Android,Android Fragments,Arraylist,我试图在片段中使用arraylist 我的arraylist在fragment类中不起作用。 请帮我修一下 在我在主活动中使用这段代码之前,然后我添加了菜单片段,我将这段代码移动到这个片段中 然后我的arraylist出现错误 “android.widget.RelativeLayout”中的“RelativeLayout(anroid.content.Context)”错误无法应用于“(com.cupaxhd.mysurah.HomeFragment)” “com.cupaxhd.mysura

我试图在片段中使用arraylist 我的arraylist在fragment类中不起作用。 请帮我修一下 在我在主活动中使用这段代码之前,然后我添加了菜单片段,我将这段代码移动到这个片段中

然后我的arraylist出现错误

“android.widget.RelativeLayout”中的“RelativeLayout(anroid.content.Context)”错误无法应用于“(com.cupaxhd.mysurah.HomeFragment)”

“com.cupaxhd.mysurah.MyAdapter”中的“MyAdapter(android.content.Context,java.util.Arraylist)”不能应用于“(com.cupaxhd.mysurah.HomeFragment,java.util.Arraylist)”

公共类HomeFragment扩展了片段{
回收视图mRecyclerView;
我的适配器我的适配器;
公共HomeFragment(){
//必需的空公共构造函数
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//为该碎片膨胀布局
视图v=充气机。充气(R.layout.fragment\u home,container,false);
mRecyclerView=v.findViewById(R.id.recyclerView);
mRecyclerView.setLayoutManager(新的RelativeLayout(this));
myAdapter=新的myAdapter(这个,getMyList());
mRecyclerView.setAdapter(myAdapter);
返回v;
}
私有数组列表getMyList(){
ArrayList models=新的ArrayList();
模型m=新模型();
m、 setTitle(“Al-Lahab”);
m、 setDescription(“苏拉·拉哈布·阿达拉·苏拉特·克-111《古兰经》);
m、 设置详细信息(“ت1614;تت㶧㶧㶧㶧㶧㶧㶧㶪㶪㶪㶪㶪㶪㶪”
);
m、 setImg(R.drawable.al_lahab);
增加(m);
收益模型;
}

您需要传递上下文而不是片段实例,并使用LayoutManager而不是RelativeLayout。如下所示:

mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

new MyAdapter(getActivity(), getMyList());

“然后我的arraylist出现错误”--请在问题中包含完整的错误消息。请帮助我解决此问题
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

new MyAdapter(getActivity(), getMyList());