Questions tagged [android-fragmentactivity]

An Activity subclass introduced through the compatibility package to provide an implementation of the Fragment framework on version below Honeycomb.

An Activity subclass introduced through the compatibility package to provide an implementation of the Fragment framework on version below Honeycomb. This class doesn't work with Fragments from the SDK, it needs the Fragment related classes from the compatibility package.

More information can be found in the documentation of the FragmentActivity.

2111 questions
62
votes
11 answers

Manage toolbar's navigation and back button from fragment in android

All of my fragments are controlled through ActionBarActivity (mainActivity), inside mainActivity a DrawerLayout is implemented and all the child fragments are pushed through drawerLayout's list item click. The problem that I'm facing is after…
59
votes
2 answers

After the rotate, onCreate() Fragment is called before onCreate() FragmentActivity

I'm using FragmentActivity and Fragments. When the application starts: FragmentActivity onCreate() <------ FragmentActivity onStart() FragmentActivity onResume() Fragment onAttach() Fragment onCreate() <------ Fragment onCreateView() Fragment…
41
votes
5 answers

commitAllowingStateLoss() in fragment activities

my app uses fragment activities, it is in portrait mode only and there is no way to rotate the screen. Originally I was using the commit() method but now I plan to indiscriminately change these to commitAllowingStateLoss() for the fragment…
CQM
  • 42,592
  • 75
  • 224
  • 366
34
votes
6 answers

Navigation drawer, handling the back button to go to previous fragments?

I'm using the built-in navigation drawer to run my app. I can't quite figure out how to handle the back button. When it's pressed I want it to load the very first fragment again. Fragment1. So when the app launches you see Fragment1 launched. They…
34
votes
1 answer

3 android fragments in viewpager, how to keep them all alive?

I have a viewpager with at least 3 fragments. If the user inputs data into A, then B, then C and goes back to A that data is lost from A. I think I read somewhere that this has to do with memory management and since fragments only connect to or…
32
votes
5 answers

Get view of Fragment from FragmentActivity

I have a FragmentActivity where I add a Fragment. Depending on some situation, I want to access Buttons from that fragment's layout and change click listeners of them. What I do is: View view = myFragment.getView(); Button myButton = (Button)…
Drastamat
  • 343
  • 1
  • 3
  • 6
30
votes
2 answers

TabHost with Fragments and FragmentActivity

I'm working on an Android App and I want to use 3 tabs for navigation using Fragments for each tab, but I don't know how to create the structure for doing it. I want to add each fragment separately because each one is different, but I don't know…
29
votes
4 answers

FragmentActivity cannot be resolved to a type

I'm trying the application from this blog. While extending the FragmentActivity, I'm getting the following error: `FragmentActivity` was not able to resolve. Am I missing any library or anything else? My code: public class Testing_newActivity…
Pratik
  • 30,639
  • 18
  • 84
  • 159
28
votes
4 answers

Fragments remain after Activity get's killed and recreated

I have a FragmentActivity (Support Fragments) where I create Fragments by code and put them into FrameLayouts. It all works fine so far. Now if I leave the App an return everything is fine as long as the system doesn't kill my Activity (or I do…
27
votes
5 answers

Bring Fragment to Front (No fragment recreation)

I have three fragments F1 F2 F3 F4 all are accessible from sidebar. all four can be called at any time and in any order, Now I want if, F1 is already clicked(created) then never again create F1, but only bring back fragment F1 to front using…
Nitin Misra
  • 4,472
  • 3
  • 34
  • 52
26
votes
3 answers

Why does the fragment's onCreateView, onCreate, onActivityCreated are called

I have an app, that deals with fragments and ViewPager. I have three fragments in a ViewPager. When you switch between them, it always causes the other two fragments to call their's onCreateView methods. How to do it only once, only when…
25
votes
1 answer

Using `onRetainCustomNonConfigurationInstance` to retain data across configuration changes

I've been programming for Android for some time, and I'm still looking for solutions to retain data over configuration changes. Aside from saving Parcelables to Activity's Bundle in onSaveInstanceState docs are suggesting using Fragment with…
25
votes
1 answer

Android non-UI Fragment usage

I am going through the Android documentation on Fragments . The layout that defines the UI of a Fragment may be defined in the layout of the Activity, in a separate .xml file or not at all. According to the documentation you can also use a…
anna
  • 585
  • 1
  • 6
  • 22
24
votes
8 answers

Calling DialogFragment from Fragment (not FragmentActivity)?

I do have a FragmentActivity which contains a Fragment list (with methods to navigate between them). In one of those fragments I need to call a DialogFragment to display a "zoom" on a Picture contained in that fragment. But it seems that you can't…
Elie Page
  • 243
  • 1
  • 2
  • 5
24
votes
5 answers

How to update-refresh Fragment in ViewPager by Main Activity programmatically

I'm building an App that use Fragment and a single MainActivity that showing different fragments in the same ViewPager to replicate the behaviour of a typical MVC application. The problem is that haven't understood how could I update the fragment…
AndreaF
  • 11,975
  • 27
  • 102
  • 168