Top "Android-fragments" questions

Fragments represent reusable behaviors or portions of the user interface in an Android app.

Understanding Fragment's setRetainInstance(boolean)

Starting with the documentation: public void setRetainInstance (boolean retain) Control whether a fragment instance is retained across Activity re-creation (such …

android android-fragments
Difference between add(), replace(), and addToBackStack()

What is the main difference between calling these methods: fragmentTransaction.addToBackStack(name); fragmentTransaction.replace(containerViewId, fragment, tag); fragmentTransaction.add(containerViewId, …

android android-fragments
getActivity() returns null in Fragment function

I have a fragment (F1) with a public method like this public void asd() { if (getActivity() == null) { Log.d("yes","…

android android-fragments android-activity null android-context
Use Toast inside Fragment

I'm trying to show a Toast Message when user click on a Button inside a Fragment. The problem is I …

android android-fragments android-activity toast
How to pass data between fragments

Im trying to pass data between two fragmens in my program. Its just a simple string that is stored in …

android android-fragments
How to use setArguments() and getArguments() methods in Fragments?

I have 2 fragments: (1)Frag1 (2)Frag2. Frag1 bundl = new Bundle(); bundl.putStringArrayList("elist", eList); Frag2 dv = new Frag2(); dv.setArguments(bundl); …

android android-fragments
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

I'm using the support library for my app. In my FragmentActivity I'm using an AsyncTask for downloading data from internet. …

android exception android-asynctask android-fragments illegalstateexception
Setting Custom ActionBar Title from Fragment

In my Main FragmentActivity, I setup my custom ActionBar title like this: LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_…

java android android-fragments android-actionbar android-fragmentactivity
How to get Toolbar from fragment?

I have ActionBarActivity with NavigationDrawer and use support_v7 Toolbar as ActionBar. In one of my fragments toolbar has custom …

android android-fragments android-actionbar android-support-library android-toolbar
In android how to set navigation drawer header image and name programmatically in class file?

In android studio 1.4.1, I have created new Navigation Drawer Project which is default.My issue is in this project there …

android android-layout android-fragments androiddesignsupport android-navigationview