android-fragmentactivity

Fragment overlaps sometimes when switching tabs [duplicate]

谁说胖子不能爱 提交于 2019-12-06 00:25:05
问题 This question already has answers here : Android: fragments overlapping issue (16 answers) Closed 5 years ago . I have a two pane layout with my buttons on the left. When a button is pressed its corresponding fragment is displayed on the right. Sometimes the fragments overlap but this is an intermittent issue. I can't replicate it all the time but it does happen public void onClick(View v) { switch (v.getId()) { case R.id.imageButtonSettingsManageBooks: SettingsManageBooksFragment mbFragment

The hierarchy of the type MainActivity is inconsistent

孤者浪人 提交于 2019-12-06 00:09:07
问题 I created a new Android project via eclipse, with a MainActivity. I added ActionBarSherlock to the project (Properties > Android and clicked Add). Then, when I replace "extends Activity" with "extends SherlockFragmentActivity" I get a compile error "The hierarchy of the type MainActivity is inconsistent". I also tried to create a project without an Activity, then created a class "MainActivity" that inherits from SherlockFragmentActivity, and there are no compile time errors, but with a run

Reading SharedPreferences data in Fragment, within FragmentActivity

与世无争的帅哥 提交于 2019-12-05 20:47:39
I'm trying to save the name the user enters on the log in screen below Settings.java to a sharedPreference , which will be read by TestFragment2.java , which is called from another FragmentActivity, SampleTabsDefault.java Settings.java private void savePrefs(String key, boolean value) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Editor edit = sp.edit(); edit.putBoolean(key, value); edit.commit(); } private void savePrefs(String key, String value) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); Editor edit = sp.edit(); edit

Refreshing fragments in FragmentActivity after sync service runs

别说谁变了你拦得住时间么 提交于 2019-12-05 20:18:17
does anybody have any elegant solution for refreshing the Views in Fragments in a FragmentActivity's ViewPager after a sync Service from a SyncAdapter runs? I've tried calling notifyDataSetChanged() and notifyDataSetInvalidated() on my adapter, as well as refreshDrawableState() on my views ( GridViews ), but to no avail. Perhaps I've been calling them from the wrong places -- I've tried doing it at setUserVisibleHint where isVisible =true, hoping to trigger it whenever the fragment comes into view, but it doesn't work. I've also been using ASync calls to the SQLite database for my data needs,

Fragment Backstack is not restored when orientation changes

﹥>﹥吖頭↗ 提交于 2019-12-05 18:01:29
I have a FragmentActivity , when the user navigates through the app, I replace the current fragment with the fragment the user has selected and add add the transactions to backstack. Everything works fine, the user can go back to the previous fragments by pressing the back button. The problem occurs when the device orientation changes: suppose the first fragment that the user sees is A, then he navigates to B and from B to C. The content inside of C is better appreciated in landscape mode, and there is a special landscape layout for C, so the user rotates the device. I would expect the user to

Adding toolbar to a FragmentActivity

北战南征 提交于 2019-12-05 16:17:11
Am extending a FragmentActivity in a class which serves as my base activity where my other activities extend from. My issue is when I extend my other activities from my base activity, I loose toolbar functionality. How can I add this to my base activity so that my activities can inherit the toolbar? Any pointers? Nischal Hada In case fragments should have custom view of ToolBar you can implement ToolBar for each fragment separately. add ToolBar into fragment_layout : <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android

Getting exception as Failure saving state: active Fragment has cleared index: -1 when I am pressing home button of android device

只愿长相守 提交于 2019-12-05 11:26:45
I am facing some weird issue while I am pressing home button of android and while starting new activity. My stacktrace is as follows 05-13 18:06:21.182: E/FragmentManager(5674): Failure saving state: active Fragment{411d96d8} has cleared index: -1 05-13 18:06:21.182: E/FragmentManager(5674): Activity state: 05-13 18:06:22.032: E/ACRA(5674): ACRA caught a IllegalStateException exception for com.itgurussoftware.android.dineback. Building report. 05-13 18:06:27.732: E/ACRA(5674): com.itgurussoftware.android.dineback fatal error : Failure saving state: active Fragment{411d96d8} has cleared index:

Nested fragment with wrong activity reference after configuration change

狂风中的少年 提交于 2019-12-05 10:27:50
I'm finally looking into the new nested fragments APIs in the support library revision 11. Everything It worked pretty well till I tried to use the activity reference held by the nested fragments. After a configuration change the childFragment doesn't seem to get detached and re-attached to the new activity. Basically after an orientation change my childFragment is in an inconsistent state from which I can't get the correct activity instance with getActivity() . I manged to get the correct one using getParentFragment() .getActivity() and it works, but I don't think that's the right way to go.

how to replace one full-screen dialog fragment with another without showing parent activity?

戏子无情 提交于 2019-12-05 10:10:46
I have an Activity that uses a single custom DialogFragment class. Its appearance is data driven, so it can look fairly different from invocation to invocation. It is "full screen", i.e. setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme); In response to the result of a network call I dismiss() the currently showing instance (if there is one) and show() a new one: final CustomDialogFragment dialog = (CustomDialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_CUSTOM); if (dialog != null) dialog.dismiss(); final CustomDialogFragment newdialog = new

Embedding Cordova WebView, Receiver is not registered

送分小仙女□ 提交于 2019-12-05 08:20:00
I have embedded the Cordova WebvView as a component to my project, everything works fine except one thing; when the back button is pressed I get an error on LogCat which says "Receiver Not Registered !" I dont think I have registered a receiver. There is also a sample project on GitHub here . I also get the same error when I run this application. What I want to do is, embed Cordova WebView into my Android project and run some javascript functions. Here is my main activity; public class MainNativeViewController extends FragmentActivity implements CordovaInterface, JavaScriptListener {