In common cases all apps with Nawigation Drawer from support v4 in android has FrameLayout for containgn stuff and ListView but I need to do it in different wat instead ListView put there a Fragment, does anyyone did something like this?
Any advices will be helpfull for me. Thanks in advance.
All methods of NavigationDrawer are using drawerView variable of type View. It means you can use any subclass of View, not only ListView, so you can take, for example, another FrameLayout as container for you Fragments and work directly with it.
Related
I need to use part of my activity layout in fragmnent, but I dont know how.
If I use overlaying FrameLayout, I will not have access to the elements behind it. And duplicate part of activity_main_layout in several fragments also is not good idea.
A fragment can't host an activity. Instead you can use nested fragments for this purpose. Fragment Inside Fragment
It looks like i need to use fragments with transparent container in the middle
I am using Android-ObservableScrollView library. Everything works great, but I have activity for holding fragments, so all views are encapsulated in the fragment. In activity there is only FrameLayout for holding fragments.
So I need to use Toolbar in my application, I have several ideas how to implement this.
Use Toolbar in activity, in this case my layout will have FrameLayout and Toolbar. In this way I have communicate with activity whenever I need to do something with toolbar, I can also obtain it by using getSupportedActionBar() from fragment.
Use Toolbar inside fragment (in its layout) setting in each fragment view creation. And each time I change fragment I have to add new Toolbar to the activity. In some fragment I am going to have different toolbars but not in all. Is it good approach to store Toolbar inside fragment.
The problem that I can see in using second approach, if there will be more than one fragment on the screen there will be also several toolbars.
Please suggest what will be the right way in this case.
Thank you.
You should use first method.
While using first method will have less problem then second one because in second method you have to define toolbar for many times which is not good programming.
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..:)
Think I have an activity with some layouts, I want to know is it possible to use layouts in activity for thats activity ViewPager items ?
is it possible ? if so , how ?
thanks
You should use a ViewPager, where each page holds a Fragment. This sample code explains how it can be done.
If you want your application to support pre-Honeycomb devices, you'll want to use the ViewPager and Fragments from the Android Support Package.
You can use viewpager with fragment. See the sample code below. I think this will be helpful for you.
http://developer.android.com/resources/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.html
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