I have a bit of a problem here; I want to use the SlidingMenu on my activity + the ViewPagerIndicator ... but I cannot use the getsupportfragmentmanager() without extending FragmentActivity or I cannot use getSlidingMenu() without extending SlidingActivity..
Is there any work arround to use getsupportfragmentmanager() without extending FragmentActivity or it isn't even possible?
Thanks in advance
(If anyone is interested ill post the code)
EDIT:
I solved the problem;
I went to SlidingActivity.java in the library and changed "extends Activity" to "extends FragmentActivity" and it worked..
Related
I have created a Fragment Activity, It displays Google Map and does other stuff.
Now i have another Activity, I want to use all the functionalities of Fragment Activity into my new Activity.
If i had Fragment, i would have easily used it in my new layout like following.
<fragment
android:id="#+id/calendarFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.activities.fragments.HeaderFragment"
tools:layout="#layout/header_fragment" />
But now i am using FragmentActivity, i cannot use above mentioned code, if i use it it gives me following error message
Caused by: java.lang.ClassCastException
and it obvious, as i passing FragmentActivity into Activity.
Kindly guide me how to reuse FragmentActivity
One simple way would be to use inheritance. Basically make 1 FragmentActivity as the base and then make implementation A (which you already have) that extends the FragmentActivity and then make implementation B which also extends it but does some things differently. It all depends on how much you want to reuse...
Just to make it completely clear. Your current FragmentActivity will be the base. Implementation A will not change very much, while B might change a lot...
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 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
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/