I have a main activity and i am using this activity to make a call to the fragment log off. The problem i am facing is i can't remove the layout of the activity from the background even though i am in the fragment. So in this case, i see both the activity layout and on top of that i see the fragment layout. I just want to remove the calling activity layout from the fragment.How do i accomplish this?
My main screen looks like this:
and my logoff screen looks like this:
my main screen layout looks like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#FFCC00"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
<LinearLayout
android:id="@+id/llProfile"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:weightSum="3"
android:visibility="gone">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<!-- android:layout_weight="2" -->
<ImageView
android:id="@+id/imgProfilePic"
android:layout_width="80dp"
android:layout_height="wrap_content" />
<!-- android:layout_weight="1" -->
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="20dp" />
<TextView
android:id="@+id/txtEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="18dp" />
</LinearLayout>
</LinearLayout>
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_sign_in"
android:layout_width="321dp"
android:layout_height="142dp"
android:layout_marginBottom="20dp"
android:layout_gravity="center"/>
</RelativeLayout>
and this is how i am calling the fragment:
Fragment fragment = null;
private ListView drawerListView;
private String[] navMenuTitles;
fragment = new LogOffFragment(mGoogleApiClient);
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
// update selected item and title, then close the drawer
drawerListView.setItemChecked(position, true);
drawerListView.setSelection(position);
setTitle(navMenuTitles[position]);
drawerLayout.closeDrawer(drawerListView);
}
onCreateView of the fragment looks like this:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_logoff, container, false);
return rootView;
}