Android, java.lang.IllegalArgumentException: No vi

2019-07-25 16:49发布

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);

0条回答
登录 后发表回答