Android,java.lang.IllegalArgumentException:找不到片段[..]的id [..]的视图

时间:2014-01-05 15:44:38

标签: java android android-fragments fragment android-framelayout

我尝试打开一个对话框,其中有一个FrameLayout。在布局中加载片段时,我得到以下异常:

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

我正确加载了Parentlayout,其他一切看起来都是正确的。

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>

为什么我会得到例外?

修改: 它现在有效。它没有做到这一点,因为FrameLayout没有实现。我只是用

main.getSupportFragmentManager().beginTransaction().replace(fl.getId(), scenegroups);

0 个答案:

没有答案