MapActivity in a fragment - android

I have a FragmentActivity:
public class parking extends FragmentActivity { }
It has 3 tabs, the second and third are lists, solved.
public class tab2 extends Fragment{ }
But the first one is a map, so, I can't extend Fragment and a MapActivity.
How can I solve it?

There is no support for MapFragment, Android team says is working on it since Android 3.0. Here more information about the issue http://code.google.com/p/android/issues/detail?id=15347&utm_source=buffer&buffer_share=acc72
But what you can do is create a Fragment that returns a MapActivity. Here is a code example. Thanks to inazaruk: https://github.com/inazaruk/examples/tree/master/MapFragmentExample
How it works:
MainFragmentActivity is the activity that extends FragmentActivity
and hosts two MapFragments.
MyMapActivity extends MapActivity and
has MapView.
LocalActivityManagerFragment hosts
LocalActivityManager.
MyMapFragment extends LocalActivityManagerFragment and with help of TabHost creates
internal instance of MyMapActivity.
if you have any doubt please let me know

Google released the Map API Version 2. This finally allows us to use a MapFragment and a SupportMapFragment. This allows adding Maps to ViewPagers and to Activities that do not extend MapActivity.

Related

Main activity with a menu and map fragment (Android app)

My main activity extends AppCompatActivity where I create and inflate my menu. I also want my main activity to contain a map fragment. This requires that my main activity extends FragmentActivity, but I cannot extend from two super classes. How am I supposed to add a map fragment to my main activity?
AppCompatActivity extends FragmentActivity, so you get all of the functionality in FragmentActivity by extending AppCompatActivity.
Well, AppCompatActivity already extends FragmentActivity, so there should be no problem.

Android viewpager in fragment

Dear ladies and gents,
First of all, please do not mark my question down. If you think that my question is too stupid please let me know and i will edit it or remove.
So my actual question is that I have an activity (extends Activity). In that activity's layout I created FrameLayout where I then attach different four fragments(so each of them extends Fragment. So in one of that fragments I would like to implements swipeable tabs(see screenshot).
I know that it is usually done by implementing viewPager and FragmentPagerAdapter, but I can not do this as if I'm calling getSupportFragmentManager in my fragment it gives my an error. If i am using getActivity().getFragmentManager() it gives me error that android.support.v4.app.fragmentmanager cannot be applied to android.app.fragmentmanager. I have to use android.support.v4.app.fragment in my fragment, because otherwise I will not be able to implement my activity's view(described at the beggining).
Any ideas or suggestions would be very appreciated.screenshot
Make sure you are using Fragment class that you extends your fragments comes from support library. You also need to use FragmentActivity to call method getSupportFragmentManager();
On the other hand, viewpager which is in your fragment need to implemented as usual that you can find on internet except getChildSupportFragmentManager();
This one called "nested fragments".
PS: I am not sure but you can also use AppCompatActivity instead of FragmentActivity. FragmentActivity and ActionBarActivity must be deprecated.
Good luck
You can use getChildFragmentManager() when using Fragments inside other Fragments.
New version of Support Library v4 (Android 4.2) resolve this problem. For do this, simply do constructor of your custom FragmentPagerAdapter like this:
public CustomFragmentPagerAdapter(android.support.v4.app.Fragment fragment)
{
super(fragment.getChildFragmentManager());
// write your code here
}
This work because new Android version approve using nested Fragments

getSupportFragmentManager on AccountAuthenticatorActivity

How can I pass the getSupportFragmentManager() to external library in AccountAuthenticatorActivity?.
I need to put a custom dialog with android-styled-dialogs: https://github.com/inmite/android-styled-dialogs
Take AccountAuthenticatorActivity and put it in your project.
Instead of
AccountAuthenticatorActivity extends Activity put AccountAuthenticatorActivity extends FragmentActivity.
Extend your class with your new AccountAuthenticatorActivity and use getSupportFragmentManager().

Android Tab Layout Tutorial -deprecated things-

I continued to do this tutorial. In this tutorial, guy used this code;
public class AndroidTabLayoutActivity extends TabActivity {
in this code TabActivity deprecated. Then I used extends ActivityGroup , it was also deprecated. I searched and I found extends Fragment , but I couldn't apply extends Fragment to tutorials' code. So how can I fix it please ?

Extend Activity with MapActivity and ActivityGroup

I'm new in Android.
How am I be able to extend an Activity with both MapActivity and ActivityGroup??
Because I need to display both a Map and a customized Tab on an Activty.
public class MainActivity extends ActivityGroup implements MapActivity
Somehow I'm not allowed to do that.
To display a tab use Fragment, coz ActivityGroup is Depreciated.

Categories

Resources