應用程序顯示錯誤。可能發生了什麼?當我返回到nav_home時,返回主片段
其他按鈕工作正常,只有nav_home不工作。
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;
}
}
登錄
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
這個XML被稱爲在我位於我ActivityMain onCreate方法和完美的作品。應用程序調用這個Fragment,但改變Fragment並返回到這個XML應用程序顯示一個錯誤。主要
<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>
XML,千萬不要以爲這是出了問題。 –