android-fragmentactivity

Global Loader (LoaderManager) for reuse in multiple Activities / Fragments

余生颓废 提交于 2020-01-01 07:42:04
问题 What I would like to achieve: I have two different fragments. I would like them both to show the same data in two forms (in a list and on a map). I would like them to share one Loader ( AsyncTaskLoader in particular). Everything works fine, but the Loader isn't re-used. Another one is created and the data is loaded twice. What I do: In the Fragment s I use LoaderManager lm = getActivity().getSupportLoaderManager(); In both of them I implement LoaderCallbacks<ArrayList<Item>> and the required

Why is my fragment onCreate being called extensively whenever I page through my applications viewPager?

孤者浪人 提交于 2020-01-01 05:01:07
问题 I'm not quite understanding this fragment lifecycle business. I have a pretty standard 3 page horizontal slider view Pager layout for a "view details" section of my app. I start my app on the middle page of the three. My FragmentActivity sets the page to page 1. mPager.setCurrentItem(1); //default to center page, current data view fragment I've been using the FragmentStatePagerAdapter because using the FragmentPagerAdapter crashed my app at times, when coming back from a suspended state for

android get value from all fragment tab

你说的曾经没有我的故事 提交于 2020-01-01 03:37:15
问题 i had declare framgmentActivity like below: mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mTabHost.addTab(mTabHost.newTabSpec("basic").setIndicator("Basic",getResources().getDrawable(R.drawable.ic_launcher)),BasicProductFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("taxes").setIndicator("Taxes",getResources().getDrawable(R.drawable.ic_launcher)),TaxesProductFragment.class, null); mTabHost

Child fragment gets destroyed for no good reason

跟風遠走 提交于 2020-01-01 03:22:11
问题 Info: I have a 2 pane layout (2 child Fragments ) inside a ParentFragment , which, of course, is inside a FragmentActivity . I have setRetainInstance(true) on the ParentFragment . On orientation change, the left child fragment doesn't get destroyed ( onCreate() doesn't get called), which is normal (because of the parent retaining its instance). Problem: On orientation change, the right fragment gets destroyed ( onCreate() gets called). Why the hell is the right fragment destroyed and the left

How to set application fragments to portrait mode only?

瘦欲@ 提交于 2019-12-30 11:14:55
问题 I have an Android app which has a main activity and 3 Fragments which are tabs. I would like the application to remain in portrait mode at all times but I can't seem to get this working. This is what I have tried, as per another stack overflow post, but I'm not sure what I'm doing wrong....does it need to be different if using fragments? <activity android:name="com.tutorial.test.activities.act1" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges=

Android Activity Flow (Login or Register and go to Home)

若如初见. 提交于 2019-12-30 10:53:06
问题 I am building an application which requires user authentication. First time a user opens the app should login or register to continue to the home screen of the app which loads some posts.. i should mention that the home screen should be a FragmentActivity to allow user navigate between 2-3 tabs.. this means that i should have another Activity (for the login screen or register) to allow the user to continue later to home. MainActivity | | --> Check If user logged in | | | | | --> Start Login

java.lang.IllegalStateException: Activity has been destroyed

為{幸葍}努か 提交于 2019-12-30 07:31:47
问题 I know that there are several similar questions. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new LoginFragment()).commit(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.i(TAG, "DZActivity onSaveInstanceState"); } @Override public void onRequestStarted() { DZActivity.this.runOnUiThread(new Runnable

java.lang.IllegalStateException: Activity has been destroyed

风格不统一 提交于 2019-12-30 07:31:30
问题 I know that there are several similar questions. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new LoginFragment()).commit(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.i(TAG, "DZActivity onSaveInstanceState"); } @Override public void onRequestStarted() { DZActivity.this.runOnUiThread(new Runnable

Can some draw lifecycle of Fragment and its parent FragmentActivity?

雨燕双飞 提交于 2019-12-30 01:35:11
问题 In Android docs, I found a specs on Activity lifecycle and on Fragment lifecycle individually, but never together. It does not seem obvious as I attached a debugger to FragmentActivity which hosts my fragment, and the life cycle is more than crazy. It looks like activity finishes first and then fragments starts, which is impossible. Fragment's lifecycle Activity's lifecycle Logically, fragment should "jump into" activity's lifecycle after its onResume and it would end before activity's

How to Remove Fragment from FragmentPagerAdapter?

被刻印的时光 ゝ 提交于 2019-12-30 00:37:09
问题 I know there are some topics about this here already but I could not find a solution which I could get to work for my case. I have a working sliding gallery using a custom FragmentActivity and FragmentPagerAdapter which holds a list of Fragments. Within the FragmentActivity is a ImageView "delete". If clicked, the function deleteMedia() is called which then should remove the current Fragment and the following Fragment should be displayed. How would I have to do that in my example?