1

I try to open a dialog in which I have a FrameLayout. While loading a fragment in the Layout I get this exception:

 java.lang.IllegalArgumentException: No view found for id 0x7f080044 (...id/selectionlayout) for fragment ScenesFragment{4166e8a0 #3 id=0x7f080044}

I loaded the Parentlayout correctly and everything else seems correct as well.

AlertDialog.Builder builder = new AlertDialog.Builder(main);
// Get the layout inflater
LayoutInflater inflater = main.getLayoutInflater();
final View v = inflater.inflate(R.layout.selectiondialog, null);
main.getSupportFragmentManager().beginTransaction().replace(R.id.selectionlayout,scenegroups).commit();
builder.setView(v);

selectiondialog.xml:

<?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:orientation="vertical"
android:padding="10dp" >

<Button
    android:id="@+id/sceneselect_back"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="back" />

<FrameLayout
    android:id="@+id/selectionlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
</FrameLayout>

</LinearLayout>

Why do I get the exception?

EDIT: It works now.It didn't do the trick, because the FrameLayout was not instanciated. I simply used

main.getSupportFragmentManager().beginTransaction().replace(fl.getId(), scenegroups);
Emanuel0101
  • 113
  • 1
  • 10
  • can you post ScreensFragment code? – Raghunandan Jan 05 '14 at 15:54
  • The Fragment works fine (in another Activity). I have loaded it the same way I did here (Framelayout etc.). It's just not finding the Framelayout "selectionlayout", which I don't understand... – Emanuel0101 Jan 06 '14 at 16:20
  • that is because FrameLayout is not in `fragment.xml` its in `selectiondialog.xml`. FrameLayout is a container. And you add the fragment to the container. Are you looking for nested fragments? – Raghunandan Jan 06 '14 at 17:33
  • Yeah, I know it's a container. I add the Container (FrameLayout) to a Dialog(-fragment), IN WICH I like to flips Views. So I'm adding the Fragment to the Layout and that's why it is in the Dialog.xml. Sorry if my explanation was not correct. – Emanuel0101 Jan 07 '14 at 13:30
  • that is not the point. Re-Read my previous comment. You can display a dialog fragment. What is the need for FrameLayout? – Raghunandan Jan 07 '14 at 13:42
  • Did you get a fix for this problem? – J28 Dec 12 '15 at 19:10
  • You can see my solution at the end of my initial post. Simply read the whole thing ;) – Emanuel0101 Dec 14 '15 at 15:38

0 Answers0