简体   繁体   中英

Fragments inside a Gridview in Android

Is it possible to accommodate a Fragments view inside a Gridview. I m unable to find any support with regards to this in the internet. My basic requirement is im unaware how many fragments i would be in need i to display wherein the number of fragments would be decided dynamically. Each fragment would contain a separate webviews inside it. Any sample code would be of great help

Fragment doesn't inherited from View. So its impossible to populate grid with fragments. GridView needs in BaseAdapter which should implement View getView method.

You should write your custom views instead of fragments.

您无法使用GridVew,但拥有GridLayout,可以在其中放置片段

Fragment is independent from view even also from activity .it has life-cycle .I mean you cant make fragment inside GridView. Either you have to make your own custom view by extending gridview .or Use only fragment. Use add and replace to do more ...if you want to play with fragment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM