Java.lang.illegalargumentexception: No View Found For Id 0x7f090047 ("project Name":id/content) For Fragment Fmmenu
Just wanted to share an issue that I have with a project that I am doing for a client. Whenever I enter to my IntroActivity and press the button to take me to MenuActivity, it cras
Solution 1:
I think I have found something.
fragmentManager.beginTransaction()
.replace(R.id.linear, fragment).commit();
As you see you try to replace the layout R.id.linear
with your fragment. But the R.id.linear
is the RelativeLayout you use in your fragment_menu.xml. You should replace the layout in your activity_menu.xml with the current fragment. So I would suggest:
fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
And in your activity_menu.xml:
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ff0a393d"><!-- Linearlayout to display Fragments --><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"android:id="@+id/container">
EDIT:
For the new error: There is a problem with your memory. This often happens when ImageViews
are filled by big ressources. So there is only one position where you use an ImageView
:
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewrootView= inflater.inflate(R.layout.fragment_menu, container, false);
ImageViewimagenView= (ImageView) rootView.findViewById(R.id.imageView1);
imagenView.setImageResource(imagen);
return rootView;
}
As you see, your imagenView is filled by the resource imagen
imagenView.setImageResource(imagen);
Probably you get the OutOfMemoryError
there. As a solution, try this:
try {
imagenView.setImageResource(imagen);
} catch (OutOfMemoryError e) {
//fill your ImageView with something smaller .. maybe a smaller resolution
Log.e("PlaceholderFragment", "Error: OutOfMemoryError")
}
Check your imagen too, whether there is a high resolution needed.
Post a Comment for "Java.lang.illegalargumentexception: No View Found For Id 0x7f090047 ("project Name":id/content) For Fragment Fmmenu"