50 個までのカスタム コントロール (スイッチ ボタン) を含むダイアログを表示したいと考えています。したがって、これを行う最善の方法は、それらをプログラムでループに追加することです。GroupView要素を1つだけ含むレイアウトでダイログを作成しようとしました:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:background="#AAAAAA"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ViewGroup
        android:layout_height="500dp"
        android:layout_width="500dp"
        android:id="@+id/dlg_view"/>
</LinearLayout>
次に、onCreateDialog(...) メソッドを使用してコントロールを追加します。
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
builder.setView(inflater.inflate(R.layout.geomap_menu, null))
          .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                 // sign in the user ...
              }
          })
          .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                  //LoginDialogFragment.this.getDialog().cancel();
              }
});
Dialog res = builder.create();
ViewGroup dlgView = (ViewGroup)res.findViewById(R.id.dlg_view);
MyControl myControl = new MyControl(this);
dlgView.add(myControl);
しかし、この方法では機能しません (InflateException がスローされます)。私は何を間違っていますか?