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 i m 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.
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.
You cannot use GridVew but you have a GridLayout, where fragments can be put
Related
im trying to implement an android aplication when your activity, cointains 3 or more 'main windows' like in the image -> 'A'. 'B'.'C'. so how is posible make when you slide you touch screen change from A, to B, for example, i was thinkin in a horizontal view, and inside of each item use a relative layout, but im not sure, its my first time with this kind of problem, thanks.
Try using android ViewPager. Each ImageView would be inside a Fragment that would reside inside your Activity. Check out this example
Use Tabbed Activity template when you want to make this type of Activity. ViewPager, Adapter and tab layout will be automatically implemented for you. Just make small changes in your Adapter according to your needs and use one Fragment for one tab and you can create as many tabs as you want in an Activity.
If you want i will post an example of an Adapter as i just implemented an Activity with 3 tabs.
To get your basics strong on ViewPager, tab layout and Fragment sections adapter read out this link.
I have a ViewPager and I want to use implement fragments for it, but I don't know what is the best way to do it, should I have multiple instances of a fragment with different views or should I have multiple fragments with their own views?
Edit:
What should I do when I have different layouts, exactly?
Check out the code on my git.
This includes infinite scrolling along with header that moves along scrolling and clickable pagerview pager with fragments with listview
You just have to replace the fragmented layout to however you want.
Im using this for my own sns and its very speedy. Make sure you have asynctask for any heavy loading
In Xamarin, I currently have two different activities and I would like to combine these together and use a ViewPager.
One activity uses the following content view: SetContentView(Resource.Layout.MapWithOverlayLayout);
The second activity uses the following content view: SetContentView(Resource.Layout.HomeScreen);
Can I please have some help to code a simple ViewPager that can add the two above content views into a ViewPager and then show each of these content views via code?
Thanks in advance
For a ViewPager, you will need Fragments instead of Activities.
Here is how to implement a ViewPager with Fragments and different layouts: How to implement a ViewPager with different Fragments / Layouts
The basic idea is that you create a Fragment for every layout you have, and then inside your FragmentPagerAdapter, load the correct Fragment depending on which page you are currently on.
This is how I am doing it in my other post and sorry about not posting the same code here.
Take a look at those links. It will help for sure.
Android:How to create different view in ViewPager?
Its a pretty simple implementation. You can define your own layouts and then use it in the view pager.
Here's my other post where you can get what you want to achieve:
How to use swipe gesture in a view pager's page with android?
Hope this helps..:)
I have been using this link to implement my two screen tabbed view,
http://developer.android.com/training/implementing-navigation/lateral.html
but my problem currently is that this demo only shows how to implement separate views on each tab such as a single TextView on each, whereas I wish to implement separate fragments on each tab that can interact with each other. For example, if a button is clicked on one fragment, I want it to change the text of a TextView on another fragment in the separate tab.
Currently I am using ONE fragment to implement both views and this is becoming complicated, because I can only do modifications to a certain view in the actual inflater of the view in the onCreateView method, rather than in the entire class.
So basically I want to separate them into 2 fragments and have them be able to interact with each other, but I am not sure how to configure them in the onCreateView method to work with the demo in the link I provided.
Thank you for any assistance you may have!
You can attach individual Fragment instances as pages of a ViewPager (instead of just simple views) using the FragmentPagerAdapter (docs link).
How to put Expanded List inside a Fragment Tab?
I have 3 fragments in one page, The 2nd Fragment consist of two tabs,I want to put an expanded List inside the second tab.please help ,Thanks :)
Correct me if I am wrong in assuming that you are using ListFragment to show the lists. If you want to use a ExpandableListView you are going to have to implement it yourself inside a normal Fragment since there is no ExpandableListFragment implemented in the APIs.
Here is a link to Android's documentation on how to implement it: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList1.html
Hope it helps.