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

android - do you ever have to add fragments to the manifest

Im using a fragment that is supposed to display a webview. When I try to instantiate it from the class that uses it I get the following warning in my logcat. 02-21 23:26:46.843: W/System.err(32468): android.content.ActivityNotFoundException: Unable …
James andresakis
  • 5,335
  • 9
  • 53
  • 88
23
votes
3 answers

Passing data back to previous fragment from current fragment

I am Using Navigation Drawer in my app. I have one MainActivity and rest of are Fragments. So the issue is Suppose i have three fragments like A,B,C. Now in A i have one button and i am sending data from A>B. For example putSring("datafrom…
chris
  • 699
  • 4
  • 12
  • 35
23
votes
5 answers

Fragment Transactions with transition - Unique transitionNames are required

I want to go from a list view to the detail view and therefore, I use following OnClickListener in my list: @Override public void onClick(View view) { Bet bet = (Bet)view.getTag(); FragmentManager fm =…
prom85
  • 16,896
  • 17
  • 122
  • 242
23
votes
10 answers

Android Spinner Dropdown arrow not displaying

my background for my fragment is white, and the arrow for the spinner does not display unless I click on it. This is the snippet from my Java file: spinner = (Spinner)v.findViewById(R.id.spinner); ArrayAdapter adapter =…
dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41
23
votes
1 answer

Proper use of sub sub fragments with (Child)FragmentManager

How do I properly use Fragments in Fragments? My (simplified) use case is following, I have an activity with a layout fragment and this fragment theirself contains a sub fragment... all fragments are added manually to their…
prom85
  • 16,896
  • 17
  • 122
  • 242
23
votes
3 answers

How to prevent calling onCreateView when back button pressed in fragment in android

In my application, I have tabbar functionality. In one tab i am displaying server data in lisview, and on clicking on that detail page for that list item will be open in new fragment. But when I press back button from that detail page, every time…
Mihir Shah
  • 1,799
  • 3
  • 29
  • 49
23
votes
3 answers

Is it possible to manually call onCreateView in a Fragment?

Is it possible to manually call the method onCreateView in a Fragment or, if not, is there some way I can simulate this invocation? I have a FragmentActivity with tabHost. Each tab contains a Fragment and I want to refresh the Fragment's view when I…
Symon_9851
  • 375
  • 1
  • 3
  • 9
23
votes
2 answers

My fragment cannot be cast to android.support.v4.app.Fragment

I created a very simple fragment to test my app and I got the following error message: 03-31 16:04:39.834: E/AndroidRuntime(7860): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.team3.domore/com.team3.domore.TabActivity}:…
user1447343
  • 1,417
  • 4
  • 18
  • 24
23
votes
1 answer

How to cache a fragment view

I'd like to cache a fragment view. My Activity has swipeable tabs and each tab calls a different fragment. But when i swipe between tabs the transition seems a quite slow because of the destruction of the fragment view, that is rebuilded during the…
Release
  • 1,167
  • 1
  • 12
  • 21
22
votes
7 answers

ViewPager Activity to notify a Fragment of a specific event

I have a ViewPager and it is using a FragmentAdapter in order to display several fragments of the same kind. Although these Fragments are basically instantiated from the same class, they are using a ListView to display different information.…
Maghoumi
  • 3,295
  • 3
  • 33
  • 49
22
votes
3 answers

Android get layout height and width in a fragment

I am working on a fragment and I want to get the dimension of a layout contained in the xml fragment layout. When I try the code RelativeLayout myLayout = view.findViewById(R.id.myLayout); myLayout.getHeight(); it returns 0. I need these…
lory105
  • 6,112
  • 4
  • 31
  • 40
22
votes
1 answer

OAuth2: query string vs. fragment

Just noticed that in OAuth2 when the requested grant type is: "code" the callback contains it in the query string parameters (after '?'). However, when the grant is "token" it is passed as a fragment (after '#'). This looks to be part of a spec…
Piotr
  • 817
  • 1
  • 8
  • 21
21
votes
1 answer

onCreateOptionsMenu not being called on FragmentActivity when run on phone version

I create an app that supports both phone and tablet version so i use the android-support-v4.jar library. My activity extends the FragmentActivity and override the onCreateOptionsMenu(Menu menu). This works fine on tablet, the onCreateOptionsMenu…
Lorensius W. L. T
  • 1,734
  • 4
  • 19
  • 31
21
votes
2 answers

Replace a fragment programmatically

I have three fragments as shown in below figure. I have added all these three fragments in LinearLayout using .xml file and when my launcher activity starts I load that .xml layout using setContentView.I have some controls on fragment2. Clicking on…
AndroidDev
  • 2,627
  • 6
  • 29
  • 41
20
votes
3 answers

Android - Fragment API for API level < 11

I have came across a problem for dynamic forms in my app, which is suited for Android 2.1 and above. I know there is new Fragment API since API level 11 (Android 3.0 Honeycomb), but also I have read an article -…
Waypoint
  • 17,283
  • 39
  • 116
  • 170