Setting Custom ActionBar Title from Fragment

What you’re doing is correct. Fragments don’t have access to the ActionBar APIs, so you have to call getActivity. Unless your Fragment is a static inner class, in which case you should create a WeakReference to the parent and call Activity.getActionBar from there. To set the title for your ActionBar, while using a custom layout, … Read more

Difference between Activity and FragmentActivity

A FragmentActivity is a subclass of Activity that was built for the Android Support Package. The FragmentActivity class adds a couple new methods to ensure compatibility with older versions of Android, but other than that, there really isn’t much of a difference between the two. Just make sure you change all calls to getLoaderManager() and … Read more

startActivityForResult() from a Fragment and finishing child Activity, doesn’t call onActivityResult() in Fragment

You must write onActivityResult() in your FirstActivity.Java as follows @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } So this will call your fragment’s onActivityResult() Edit: the solution is to replace getActivity().startActivityForResult(i, 1); with startActivityForResult(i, 1);

Android ViewPager with bottom dots

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.view.ViewPager> <android.support.design.widget.TabLayout android:id=”@+id/tabDots” android:layout_alignParentBottom=”true” android:layout_width=”match_parent” android:layout_height=”wrap_content” app:tabBackground=”@drawable/tab_selector” app:tabGravity=”center” app:tabIndicatorHeight=”0dp”/> </RelativeLayout> Hook up your UI elements inactivity or fragment as follows: Java … Read more