android-fragmentactivity

Are Fragments and Fragment Activities inherently faster than Activities?

梦想与她 提交于 2019-12-05 06:41:04
Are Fragments and Fragment Activities inherently faster than Activities? If I don't need to load my activity in fragments, should I be using FragmentActivities and Fragments over Activities? Reason I am asking is because I have been using Activities, exclusively, for years, and the Facebook SDK as well as Google Maps 2.0 have forced me to use Fragments, and I wonder now if they are inherently "better" or not, versus some other implementation. If this "not constructive" or "too open ended" then obviously the answer is "no". But if there are some Google developer documents or blog on this exact

Crash in Marshmallow Fragment Activity for Maps

筅森魡賤 提交于 2019-12-05 06:32:18
I am using fragmentActivity for maps.In Java class getting error on setContentView. My Mapscreen.java is like: It is working fine on some devices showing crash on marshmallow only.Or is there any other reason? public class MapScreen extends FragmentActivity implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_screen); .... SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager() .findFragmentById

Where Fragment save its State when FragmentTransaction.Replace?

痴心易碎 提交于 2019-12-05 06:20:56
问题 Backgroud: i have a menu on the left, and different scrollable contents on the right. i wanted to save the scrolled position. But i failed. Then ... I have set up a very simple project to test it. In words, i have a menu on the left, and different contents all holding an <EditText> on the right. (of the same class though, they are of different instances) In codes, (very simple) content.xml <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" android

How to navigate from one Fragment to another?

巧了我就是萌 提交于 2019-12-05 05:55:25
问题 Here is my code: activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <android

FragmentPagerAdapter not restoring fragments upon Orientation Change

旧街凉风 提交于 2019-12-05 04:43:06
EDIT: I found out that the Activity is saving the instance, but the Fragments saved data is not making it up to the Activity savedInstanceState. I'm saving the current time in the outState, but its not making its way all the way up, as the activity has nothing in its SavedInstanceState for the time and returns 'null' for the time if I print it to the logcat.... I am building an application that has the a countup and countdown timer built in. The basic hosting activity for the timers is a FragmentActivity which hosts a FragementPagerAdapter that inflates two fragments within the code (I do not

YouTubePlayerSupportFragment starts duplicate Activity

陌路散爱 提交于 2019-12-05 04:14:28
I am using a YouTubePlayerSupportFragment to embed a YouTube video in my app. When embedded it works very well, the video plays, everything is great. When I tap the Fullscreen button my embedded YouTube video fragment, the first strange thing happens: It instantiates a new copy of the existing enclosing Activity... and I have no idea why. I have one Activity, RootActivity, which displays several fragments in a ViewPager. The fragment I'm dealing with at the moment is called EasyModePurchaseFragment. That EMPF has the YouTubePlayerSupportFragment embedded in its layout xml: <fragment android

Android getActivity() always returns null inside fragment

空扰寡人 提交于 2019-12-05 03:21:48
I have a strange problem in which I encountered:The getActivity() method always returns null inside fragment. I calling it after the onAttach() and onCreateView() are finishing their run. This fragment lives inside a FragmentActivity() that contains stack of fragments, and the way I adding fragment to it is: (This code is being called from the onCreate() of the Fragment Activity()) SmartFragment fragment; fragment = (SmartFragment) Fragment.instantiate(this, fragmentClassName, params); mStackOfFragments.add(fragment); FragmentTransaction trans = getSupportFragmentManager().beginTransaction();

Can fragment be created with only one instance

家住魔仙堡 提交于 2019-12-05 01:55:26
问题 I was just wondering, can fragment creation only have one instance or singleton? I went through Google iosched project too. They simply create Fragment a = new Fragment(); Whenever they want... Suppose eg: public static FragmentManager instance; public static FragmentManager getInstance() { if (instance == null) { instance = new FragmentManager(); } return instance; } public TestFragment getTestFragment() { if (testFragment == null) { testFragment = new TestFragment (); } return testFragment

AsyncTask runs on each page of the ViewPager

家住魔仙堡 提交于 2019-12-04 23:35:22
I have 3 Tabs like in the android development tutorial Now what I want to do is very simple I use Fragments on each page. I want to show different content from a rss feed on each page. The problem is when I go to the next tab it runs AsyncTask (which is in onCreateView) of the previous Fragment. So you start on Page 1 it loads the content fine. Then when you go to Page 2 is runs the onCreateView of the Fragment of Page 1 again. And obviously gives an NullException. The point is it should not be running AsyncTask of Page 1 at all at that Page 2. I don't think there is any example code needed if

How to make particular tab in FragmentTabHost has multiple fragment navigations like tabgroupactivity

孤者浪人 提交于 2019-12-04 18:09:38
I created three tabs using FragmentTabHost. Now I need to make all the navigation are under the tabs. How can I get this. I need to get what we get using TabGroupActivity. Tab1 --->frag1-->frag2 Tab2 --->frag3 Tab3 --->frag4--->frag5 I have used fragmentTransaction.add(), fragmentTransaction.remove(), fragmentTransaction.replace(). These three methods but nothing give solution. Replace method shows new fragment view on top of existing fragment view. Remove and Add , from these two remove only works, add does not works. Thanks in advance. TabHostMain.java @Override protected void onCreate