I have the same issue has this post: android.support.v4.app.Fragment: undefined method getChildFragmentManager(). I need to use getChildFragmentManager() because I'm using nested fragments.
My problem is: the solution in the other post does not work for me:
My SDK is updated.
I got my android-support-v4 from the SDK folder.
I added android-support-v4 both the my project and ABS.
Here is my libs:
How can I correctly use this method?
Not sure if you've resolved your issue yet, but I was having the same issue and I resolved it. The getCildFragmentManager() method is a method of the class Fragment and not FragmentActivity. Just because your class extends fragment activity does not mean you'll have access to this method. What I did is I created an instance of my fragment in which I wanted to place the child fragment and invoked the method through that fragment instance. There are obviously other approaches to this, but this worked for me.
maybe something in your android manifest, look at the header or 'footer of your android manifest about minimum SDK version.
This is because by using old android.support.v4.
once you change the latest library.it will solved
I solved it by change it.
Hope it will work
Related
i need help for this . I realize sth very strange about this. In order to disable the Action bar (Title) , i need to add in this code
requestWindowFeature(Window.FEATURE_NO_TITLE);
So this only works I change from
extends AppCompatActivity
To this
extends Activity
So after changing that, I got error for the getFragmentManager.
Please have a look at the screenshot. And let me know if u guys have any idea wads going on? THx
Use getSupportFragmentManager() instead of getFragmentManager().
AppCompatActivity is v4 library therefore required to use v4 functions
And to use it in Activity instead of Activity change it to FragmentActivity. Then you can use getSupportFragmentManager()
requestWindowFeature() is not supported in AppCompatActivity thats why you could not use that method with AppCompatActivity.
Also if you are using AppCompatActivity you need to use SupportFragment and if you use Activity then use Fragment.
If you are using this import import android.support.v4.app.Fragment;,
then you must use getSupportFragmentManager.
Hope this helps.
You have to use the Compat method getSupportFragmentManager() instead of the regular one.
That's because it returns an object of type android.app.FragmentManager which is the type of the object where you're trying to store it.
If you use the regular method getFragmentManager() it'll return an object of type android.app.FragmentManager, which is an incompatible type.
I came across this article but this article suggests replacing the FragmentActivity's code with that of the old Activity code. I can do that but would like to know if there's a way to just create Activity instead. I updated to ADT v22.6 today. Could that be the problem?
Another problem is that this requires a min-SDK of 7 while right now I want a min-SDK of 3.
Also, I am using Eclipse and not Android Studio.
Thanks in advance!
The new ADT 22.6 has new feature added that it will automatically create the any new activity as FragmentActivity not an single activity. So if you wish to create an Activity you can create it by explicitly creating separate class and extends Activity.
I'm afraid that google is enforcing us to use fragments activities instead of plain activities now. You either can go back to an SDK previous to 22.6 or just create the activities by just extending the class, adding a layout and adding the activity reference to the manifest.
I'm look for the easiest way to get an ActionBar instance from a Fragment using AppCompatLibrary and API 8.
Already tried things like
getActivity().getSupportActionBar()
but no luck.
Try to cast it:
((YourActivity)getActivity()).getSupportActionBar()
I am playing around the fragments tutorial found here on section 21. It works fine when my build target is android 4.0 but when i try to change it to make it work with android 2.2, i get Error inflating class fragment on the line setContentView(R.layout.main); on MainActivity class.
I already added the support package, changed classes ListFragment and DetailFragment to extend android.support.v4.app.ListFragment and android.support.v4.app.Fragment respectively. There are no compile errors.
Did I miss something? TIA!
--EDIT---
Made it work. I changed DetailActivity.java and MainActivity.java to extend FragmentActivity instead of just Activity. Everything's okay now. But still don't know why I have to do that.
Changed DetailActivity.java and MainActivity.java to extend FragmentActivity instead of just Activity.
Using the v4 Library APIs
I want to use google maps as one of the fragments of many. I found no other way then the one mentioned in the following way...
https://stackoverflow.com/a/8126287
and I was successful
But now I have 2 problems
I want to call a public method of the MyMapActicity(MyMapActivity is created as mentioned in the link given above) from another fragment. i.e. e.g. if I have fragmentA as some other fragment and MapFragment as a fragment related to MyMapActivity(created with help of above link) then I want to call a method from MyMapActivity from FragmentA. How do I do this.
I also want to resume the fragment with it is called...
I got my answer at:
https://stackoverflow.com/a/8126287
The link also provides a very nice example to follow. As I have only one activity this worked for me.
Have you tried using Action Bar Sherlock? http://actionbarsherlock.com/