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
2
votes
0 answers

using CountDownTimer with fragment

I've a CountDownTimer that runs in a fragment normally. When I try to rotate the phone i don't visualize the count down on the timerView TextView. This is the code of CountDownTimer private void startTimer(int min, int sec) { …
adev
  • 367
  • 1
  • 3
  • 20
2
votes
2 answers

Android: Switching between different fragments using tabs

I'm trying to implement toolbar tabs, and have each tab inflate a different fragment, however I am stuck with the error: java.lang.RuntimeException: Unable to start activity…
Daniel Kim
  • 267
  • 3
  • 16
2
votes
1 answer

Wrong position value in Android ViewPager

I'm trying to implement 3 slides composed of 3 fragments (or 3 layouts) with ViewPager and I want to know which slide I currently show in order to display the appropriate content. In simpler words, I want content 1 on slide 1, content 2 on slide 2…
keepthepeach
  • 1,621
  • 2
  • 20
  • 27
2
votes
2 answers

Garbage collection of a fragment in java

This may be a stupid question but i have little knowledge of garbage collection. When i looked up info about it, it became clear that nullifying an object sets it's reference count to 0 so it becomes eligble for garbage collection So i wanted to…
DennisVA
  • 2,068
  • 1
  • 25
  • 35
2
votes
1 answer

How can I put a ViewPager inside a Fragment?

My intention is to put a ViewPager with 2 tabs inside a Fragment. If it isn't possible please tell me an alternative... But I would prefer to use ViewPager, because of the swipe effect between tabs. Thank you.
2
votes
1 answer

Application not Result when user back from fragment?

I am working on android application .There are 4 tab on Home screen . there are multiple fragment under each tab.I am moving from fragment to second fragment and back on first fragment . when i again moves on second fragment . it does not show any…
2
votes
3 answers

How can i setOnClickListener in Adapter And access From Fragment?

I am developing an app like google Play Music! the thing is like that app i have a popupmenu for each row on my gridview. I'm setting grid view adapter from fragment which implements onClickListener. question is: how can i set onclicklistener for…
Mahdi Giveie
  • 630
  • 1
  • 8
  • 25
2
votes
1 answer

pass data to statically included fragment from fragment activity

I have a fragment defined in my xml layout and I want to pass data to it from my fragmentactivity. Is that possible ? I don't want to include the fragment at run time because I am not planning to change fragments during the life of the…
Nayra Ahmed
  • 657
  • 1
  • 9
  • 29
2
votes
1 answer

Fragment hosting another fragment, how to reference host fragment?

I have a fragment which contains a ViewPager. This ViewPager is obviously populated by other Fragments. My question is, is there any way (something resembling getActivity()) for the Fragment in the ViewPager to get a reference to the host Fragment?
The Hungry Androider
  • 2,274
  • 5
  • 27
  • 52
2
votes
2 answers

Using fragment more than one time with new values with backstack maintain

I am making an app using sliding menu and tab in bottom...whole app is fragment based..I am facing some problem that is I am using fragment A then click on a button and go to fragment B,in Fragment B there is a button on clicking on this button the…
userAndroid
  • 586
  • 2
  • 9
  • 26
2
votes
1 answer

Refresh webView in fragment tab

I'm using fragment tab. I need the webView to refresh to the original url when user clicks on the title. This is my code for now. MainActivity.java package com.cn1304w.munch; import android.app.Activity; import android.os.Bundle; import…
2
votes
1 answer

Tabs in a class that extends fragment

I'm reading many tutorial how to implement tabs in a class that extends FragmentActivity,but no one about how to implement tabs in a class that extends Fragment I created with AndroidStudio a new project with a NavigationDrawerFragment:this…
Giovanni Far
  • 1,623
  • 6
  • 23
  • 37
2
votes
2 answers

how to use shared preferences in multiple fragment files

I need to use shared preferences in multiple fragment files (cant use activity files) I have to store several string lines. How do I initialize shared preferences in my fragments? How do I write / read to it? Do I need to initialize it in my main…
user2864772
  • 53
  • 1
  • 4
  • 12
2
votes
1 answer

How to display Activity with 3 fragments in scrolling ListView?

I have an Activity which contains 3 Fragments. And all the 3 Fragments have ListView in them. I would like to know how to display the 3 Fragments in the ScrollView in same Activity? Please let me know the solution. Thanks.
2
votes
3 answers

View Pager with huge number of fragment

I have to change the views on swipe. This can be obtained through view pager. But I have 60 views and creating 60 different fragment will not be a good approach. Please someone guide me what will be the best way to design swiping 60 views.
megha
  • 301
  • 5
  • 18