Android 我是Recyclerview的新手。我想为每个bottomnavigationview项目显示Recyclerview。我如何才能做到这一点?

Android 我是Recyclerview的新手。我想为每个bottomnavigationview项目显示Recyclerview。我如何才能做到这一点?,android,android-recyclerview,Android,Android Recyclerview,这是我在stackoverflow中的第一个问题。如果您不理解任何内容,我很抱歉:我应该使用fragment而不是Framelayout吗 <android.support.v7.widget.RecyclerView android:id="@+id/featurerecyclerid" android:layout_width="match_parent" andro

这是我在stackoverflow中的第一个问题。如果您不理解任何内容,我很抱歉:我应该使用fragment而不是Framelayout吗

            <android.support.v7.widget.RecyclerView
                android:id="@+id/featurerecyclerid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </FrameLayout>
```
下面是我的导航xml

            ```
<FrameLayout
                android:id="@+id/fragment_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@id/bottomnavid"
                >

            </FrameLayout>
            <android.support.design.widget.BottomNavigationView
                android:id="@+id/bottomnavid"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                app:menu="@menu/bottom_nav"
                /> 
  ```   
            <android.support.v7.widget.RecyclerView
                android:id="@+id/featurerecyclerid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </FrameLayout>
```
该项目没有任何错误,但它没有显示recyclerview我如何在这一部分实现recyclerview,我认为问题就在这里..请帮我解决

            <android.support.v7.widget.RecyclerView
                android:id="@+id/featurerecyclerid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </FrameLayout>
```
        public class Feature extends Fragment {
            ArrayList<String> Citynames = new ArrayList<>    (Arrays.asList("dhaka","rongpur","bagura","sylhet","vhola"));
            @Nullable
            @Override
            public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
                final View view  = inflater.inflate(R.layout.feature,container,false);
                final FragmentActivity c = getActivity();
                final RecyclerView recyclerView = view.findViewById(R.id.featurerecyclerid);
                LinearLayoutManager layoutManager = new  LinearLayoutManager(c);
                recyclerView.setLayoutManager(layoutManager);
                 Myadapter myadapter = new Myadapter(Citynames,c);
                recyclerView.setAdapter(myadapter);
                return inflater.inflate(R.layout.feature,container,false);
            }
        }


 ```           
公共类功能扩展了片段{
ArrayList Citynames=新的ArrayList(Arrays.asList(“达卡”、“荣普尔”、“巴古拉”、“锡尔赫特”、“沃拉”);
@可空
@凌驾
创建视图时的公共视图(@NonNull LayoutInflater inflater、@Nullable ViewGroup container、@Nullable Bundle savedInstanceState){
最终视图=充气机。充气(右布局。特征,容器,假);
最终碎片活动c=getActivity();
final RecyclerView RecyclerView=view.findViewById(R.id.featurerecyclerid);
LinearLayoutManager layoutManager=新的LinearLayoutManager(c);
recyclerView.setLayoutManager(layoutManager);
Myadapter Myadapter=新的Myadapter(Citynames,c);
recyclerView.setAdapter(myadapter);
返回充气机。充气(右布局。特征,容器,假);
}
}
```           

我不确定您到底想做什么,在我看来您对布局有什么错误,在尝试recycler view之前,首先练习一些不同类型的布局,这将有助于您了解design object在xmal属性中的工作原理,请像这样尝试您的布局

            <android.support.v7.widget.RecyclerView
                android:id="@+id/featurerecyclerid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        </FrameLayout>
```
  <FrameLayout
     android:id="@+id/fragment_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@id/bottomnavid"
                >
     <android.support.v7.widget.RecyclerView
                android:id="@+id/featurerecyclerid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
    <android.support.design.widget.BottomNavigationView
                android:id="@+id/bottomnavid"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                app:menu="@menu/bottom_nav"
                />
            </FrameLayout>

我想在framelayout上显示一个recyclerview。我想在活动的底部显示一个bottomnavigationview,在底部上方有一个framelayout,我想在其中放置一个recyclerview。一切都已完成(适配器、视图支架、cardview)但是recyclerview没有显示编辑您的问题。首先,发布您的所有布局,包括适配器布局和适配器类。我的意思是,没有部分发布代码,您犯了一些我在回答中所指的错误。此外,还修复了此问题,希望您能够理解此问题。在我在回答中提到的onViewCreated()方法中设置您的recycler视图和适配器