when I return to nav_home the application displays an error . What might be happening?
The other buttons are working perfectly , only nav_home is not working.
public boolean onNavigationItemSelected(MenuItem item) {
FragmentManager fm = getFragmentManager();
int id = item.getItemId();
if (id == R.id.nav_home) {
fm.beginTransaction().replace(R.id.content_frame, new MainFragment()).commit();
} else if (id == R.id.nav_perfil) {
fm.beginTransaction().replace(R.id.content_frame, new Perfil()).commit();
}else if (id == R.id.nav_cadprof) {
fm.beginTransaction().replace(R.id.content_frame, new CadProfFragment()).commit();
} else if (id == R.id.nav_tabelapreco) {
fm.beginTransaction().replace(R.id.content_frame, new TabelaPreco()).commit();
} else if (id == R.id.nav_ajuda) {
fm.beginTransaction().replace(R.id.content_frame, new Ajuda()).commit();
} else if (id == R.id.nav_sobre) {
fm.beginTransaction().replace(R.id.content_frame, new Sobre()).commit();
} else if (id == R.id.nav_slogan) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
Log
05-07 12:54:25.364 27082-27082/com.caseb.case_beauty_ E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.caseb.case_beauty_, PID: 27082
android.view.InflateException: Binary XML file line #18: Error inflating class fragment
This XML is called in my onCreate method located in my ActivityMain and works perfectly . The application calls this Fragment but to change Fragment and return to this XML application shows an error.
XML fragment Main
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.caseb.case_beauty_Fargments.MainFragment">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/map"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
tools:context="com.caseb.testemaps.MapsActivity"
tools:layout="@layout/content_main" />
<Button
android:id="@+id/bt_estimavalor"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@drawable/screen_border"
android:backgroundTint="#66e72bac"
android:text="Estimar Valor"
android:textColor="#ffffff" />
<Button
android:id="@+id/bt_enviasolicita"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/screen_border"
android:backgroundTint="#66e72bac"
android:text="Enviar Localização e Solicitar"
android:textColor="#ffffff"
android:textStyle="bold" />
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>