Questions tagged [fragment]

**DO NOT USE**: fragment is an ambiguous tag, used to refer to numerous technologies. Prefer less ambiguous tags. For Android Fragments, use [android-fragments]. For URL fragments, use [url-fragment]

'fragment' Tag Disambiguation

8161 questions
27
votes
6 answers

GetFragmentManager.findFragmentByTag() returns null

getFragmentManager().beginTransaction() .replace(R.id.graph_fragment_holder, new GraphFragment(), "GRAPH_FRAGMENT") .commit(); getFragmentManager().beginTransaction() …
John Moffitt
  • 5,730
  • 7
  • 30
  • 39
27
votes
10 answers

How to move from one fragment to another fragment on click of an ImageView in Android?

I have an ImageView. I want to move from one fragment to another fragment on a click of an Imageview, the same way like we can move from one activity to another using Intent i=new…
anu_r
  • 1,602
  • 7
  • 30
  • 61
27
votes
12 answers

Intent from Fragment to Activity

I was trying to go to another page using button, but it always fail. Here is my First Class with its XML: public class FindPeopleFragment extends Fragment { public FindPeopleFragment(){} @Override public View…
AndroidNewbie
  • 669
  • 3
  • 16
  • 23
27
votes
8 answers

Android 4.4 — Translucent status/navigation bars — fitsSystemWindows/clipToPadding don't work through fragment transactions

When using the translucent status and navigation bars from the new Android 4.4 KitKat APIs, setting fitsSystemWindows="true" and clipToPadding="false" to a ListView works initially. fitsSystemWindows="true" keeps the list under the action bar and…
afollestad
  • 2,929
  • 5
  • 30
  • 44
27
votes
6 answers

How to open navigation drawer on button click in main fragment?

I have made an app with one activity which uses a navigation drawer to open a number of different fragments. I have the actionbar drawertoggle, but it is not very visible. If I place a button in the onCreateView in my main fragment(the fragment that…
user2729524
  • 281
  • 1
  • 3
  • 5
27
votes
8 answers

MapFragment in Fragment, alternatives?

I need your help... I work on it until 3 days. My app is working with fragments. One of these fragments has to display a map from the Google Maps V2 api for Android. Currently, I'm using a MapFragment, but no surprise, a fragment in a fragment is…
Kyu_
  • 800
  • 4
  • 10
  • 18
26
votes
5 answers

How to delete a specific fragment from back stack in android

I have a problem about removing a specific fragment from back stack.My scenario is like this.Fragment-1 is replaced with Fragment-2 and then Fragment-2 is replaced with Fragment-3. Calling order; Fragment-1-->Fragment-2-->Fragment-3. When Fragment-3…
nihasmata
  • 652
  • 1
  • 8
  • 28
26
votes
9 answers

Show / hide Android softkeyboard on fragment replace

I have an Activity with a fragment. Let's say a list fragment with a list of things. Now I want to let the user add a thing, so I use the FragmentManager to replace the list fragment with an insert fragment which has an EditText. The EditText has…
Maniac
  • 774
  • 2
  • 7
  • 11
26
votes
4 answers

v4 getFragmentManager with Activity - Incompatible types

I have a simple activity which runs as expected. import android.app.Activity; import android.app.FragmentManager; // import android.support.v4.app.FragmentManager; import android.os.Bundle; public class MainActivity extends Activity { …
David
  • 1,050
  • 1
  • 16
  • 31
26
votes
9 answers

Using onBackPressed() in Android Fragments

I am working on a project and I need to be able to use the back button in each fragment to navigate between previous fragments, I have methods written to do so by using a back arrow in the action bar, however, I want to be able to use the same…
DJ-DOO
  • 4,545
  • 15
  • 58
  • 98
25
votes
4 answers

How to pass data from a fragment to a dialogFragment

I know that this was asked before, but I dont quite understand how to implement it. I have a fragment "myFragment" in which I create an object of a "myDialogueFragment". I want to pass some value to the myDialogueFragment when I invoke it from the…
phedon rousou
  • 1,740
  • 5
  • 17
  • 24
24
votes
1 answer

Show fragment as a dialog or as a usual activity

In my app I've got a fragment which is called "About". On handhelds I want this fragment to look like a usual activity but on tablets I want it to be a dialog. Which way is preferred to handle this situation?
nixan
  • 523
  • 1
  • 6
  • 13
24
votes
4 answers

Add onOptionsItemSelected calling in Fragment

@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in…
Nevermore
  • 1,663
  • 7
  • 30
  • 56
24
votes
8 answers

Fragment still exists after remove?

1 Add two fragments to FragmentManager FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft1 = fm.beginTransaction(); ft1.add(containerId, fragment1,…
Jingqi Xu
  • 289
  • 3
  • 6
23
votes
4 answers

Fragment onHiddenChanged not called

I recently added Fragments to my applications. For a new application i'll need to get notified as soon as my fragment is shown. So i can do some calculations as soon as my fragment is shown again. My Fragment is used with a TabIndicator and it's…
mikepenz
  • 12,708
  • 14
  • 77
  • 117