android-fragmentactivity

Navigation drawer, handling the back button to go to previous fragments?

限于喜欢 提交于 2019-11-26 15:37:46
问题 I'm using the built in navigation drawer to run my app. I can't quite figure out how to handle the back button. When it's pressed I want it to load the very first fragment again. Fragment1. So when the app launches you see Fragment1 launched. They can then click on Fragment 2-5 to go to other pages. Within all of these pages I want the back button to take the user back to Fragment1. The only place the user should be able to exit the app via the back button is Fragment1. SInce it's all handled

Android ViewPager with bottom dots

时光毁灭记忆、已成空白 提交于 2019-11-26 15:36:35
I want to add 3 bottom dots to my ViewPager, like this. I use FragmentActivity and support library ViewPager. No need for that much code. You can do all this stuff without coding so much by using only viewpager with tablayout . Your main Layout: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v4

commitAllowingStateLoss() in fragment activities

爱⌒轻易说出口 提交于 2019-11-26 15:32:09
问题 my app uses fragment activities, it is in portrait mode only and there is no way to rotate the screen. Originally I was using the commit() method but now I plan to indiscriminately change these to commitAllowingStateLoss() for the fragment activities Is there any reason not to indiscriminately do this without re-evaluating each individual case where I use a fragment? 回答1: If I understand correctly you mean : Is there any reason NOT to indiscriminately do this without re-evaluating each

startActivityForResult() from a Fragment and finishing child Activity, doesn&#39;t call onActivityResult() in Fragment

我怕爱的太早我们不能终老 提交于 2019-11-26 14:12:18
FirstActivity.Java has a FragmentA.Java which calls startActivityForResult() . SecondActivity.Java call finish() but onActivityResult never get called which is written in FragmentA.Java . FragmentA.Java code: @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // some code Intent i = new Intent(getActivity(), SecondActivity.class); i.putExtra("helloString", helloString); getActivity().startActivityForResult(i, 1); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult

FragmentPagerAdapter getItem is not called

不羁的心 提交于 2019-11-26 11:49:55
问题 I am not able to reuse fragment in FragmentPagerAdapter.. Using destroyItem() method, It is deleting the fragment but still does not called getItem() again..There are just 2-3 Images so I am using FragmentPagerAdapter Instead of FragmentStatePagerAdapter.. public class ExamplePagerAdapter extends FragmentPagerAdapter { ArrayList < String > urls; int size = 0; public ExamplePagerAdapter(FragmentManager fm, ArrayList < String > res) { super(fm); urls = res; size = urls.size(); } @Override

FragmentActivity cannot be resolved to a type

大城市里の小女人 提交于 2019-11-26 10:31:42
问题 I\'m trying the application from this blog. While extending the FragmentActivity , I\'m getting the following error: `FragmentActivity` was not able to resolve. Am I missing any library or anything else? My code: public class Testing_newActivity extends FragmentActivity { // here the FragmentActivity getting error package not found for import /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /

Default Activity not found in Android Studio

旧街凉风 提交于 2019-11-26 09:29:27
问题 I just upgraded to Android Studio 0.2.8 and I am getting an error that says \"Default Activity not found\" when I try to edit the run configurations. When I launch Android Studio I get this error \"Access is allowed from event dispatch thread only\" The activity I am using is a fragment activity. So far I\'ve tried rebuilding and invalidate caches/restart. Both were of no use. Please let me know what I can do to fix the problem. 回答1: In Android Studio, right click on the project and choose

What is the difference between Fragment and FragmentActivity?

落爺英雄遲暮 提交于 2019-11-26 06:53:38
问题 My question is apart from the obvious inheritance differences, what are the main differences between Fragment and FragmentActivity? To what scenarios are each class best suited? I\'m trying to get an understanding of why both of these classes exist... 回答1: A Fragment is a section of an Activity , which has: its own lifecycle receives its own input events can be added or removed while the Activity is running. A Fragment must always be embedded in an Activity . Fragments are not part of the API

Android - Activity vs FragmentActivity? [duplicate]

元气小坏坏 提交于 2019-11-26 06:15:53
问题 This question already has answers here : Difference between Activity and FragmentActivity (2 answers) Closed 5 years ago . I am new in Android. I want to build an app with tab format. I found many documentation where Activity has been used. Also in many cases have used FragmentActivity . I am not sure which will be better to start. Please suggest me should I use Activity or FragmentActivity to start development in tab format? 回答1: ianhanniballake is right. You can get all the functionality of

“Failure Delivering Result ” - onActivityForResult

限于喜欢 提交于 2019-11-26 06:12:20
问题 I have a LoginActivity (User Logs in). It is basically its own Activity that is themed like a dialog (to appear as if a dialog). It appears over a SherlockFragmentActivity . What I want is: If there is a successful login, there should be two FragmentTransaction \'s to update the view. Here is the code: In LoginActivity , if successful login, setResult(1, new Intent()); In SherlockFragmentActivity : @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super