独自のレイアウトを使用して DialogFragment を作成しようとしています。
私はいくつかの異なるアプローチを見てきました。レイアウトは OnCreateDialog で次のように設定されることがあります: (私は Mono を使用していますが、Java には多少慣れています)
public override Android.App.Dialog OnCreateDialog (Bundle savedInstanceState)
{
base.OnCreateDialog(savedInstanceState);
AlertDialog.Builder b = new AlertDialog.Builder(Activity);
//blah blah blah
LayoutInflater i = Activity.LayoutInflater;
b.SetView(i.Inflate(Resource.Layout.frag_SelectCase, null));
return b.Create();
}
この最初のアプローチは私にとってはうまくいきます...使用するまではfindViewByID.
、少しグーグルで調べた後、オーバーライドを含む2番目のアプローチを試しましたOnCreateView
OnCreateDialog
そのため、レイアウトを設定する 2 行をコメントアウトし、これを追加しました。
public override Android.Views.View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.Inflate(Resource.Layout.frag_SelectCase, container, false);
//should be able to use FindViewByID here...
return v;
}
これは私に素敵なエラーを与えます:
11-05 22:00:05.381: E/AndroidRuntime(342): FATAL EXCEPTION: main
11-05 22:00:05.381: E/AndroidRuntime(342): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
私は困惑しています。