Je suis en train de mettre en œuvre un fragment de base et l'activité et il jette une erreur:Android Fragment donnant « erreur fragment de classe de gonflage »
Voici mes classes:
classe fragment:
public class MyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout._fragment_dds_image, container, false);
return view;
}
}
Mon fichier XML Fragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000FF"
android:orientation="vertical" >
Mon activité qui tente d'afficher le fragment:
public class DDSViewActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ddsview);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.ddsview, menu);
return true;
}}
Le fichier XML pour l'activité:
<LinearLayout 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" >
<fragment
android:id="@+id/fragment1"
android:name="dds.MyFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
Quand je lance cela, il donne em l'erreur suivante:
Impossible de démarrer activty ComponentInfo {com.example.electronicmenu/dds.DDSViewActivity}: android.view.InflateException: ligne de fichier xml binaire # 10: Erreur lors du gonflement du fragment de classe.
Afficher la trace complète de la pile de logcat – Karakuri
https://www.dropbox.com/s/sxtywgav3gbapm6/Error%20to%20Stack%20Trace.txt – Zapnologica