0
當我試圖在對話框中添加片段時,該應用程序崩潰。崩潰說「沒有查看發現ID 0x01276」Xamarin中的自定義對話框中的片段事務期間發生崩潰Android
這是對話的佈局文件(my_dialog_layout.axml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/fragment_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
這是在打開對話框和片段交易代碼
class CustomDialog : Dialog{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState)
SetContentView(Resource.Layout.dialog_fragment_layout);
var myCustomFragmnent = new MyCustomFragment(_context);
// Start Fragment Transaction Process
var transaction = FragmentManager.BeginTransaction();
// Here is a crash saying (No View found for ID 0x01276....)
transaction.Add(Resource.Id.fragment_container, myCustomFragmnent);
transaction.Commit();
}
}