ダイアログにXMLレイアウトを設定する方法
ダイアログでXMLレイアウトを表示する場合は、以下のようにLayoutInflaterでViewを生成してsetViewメソッドにて設定します。
//コンテキストからインフレータを取得 LayoutInflater inflater = LayoutInflater.from(this); //レイアウトXMLからビュー(レイアウト)をインフレート final View updateView = inflater.inflate(R.layout.a1_update,null); //ダイアログ設定 AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setIcon(R.drawable.icon); ad.setTitle("タイトル"); ad.setView(updateView); updateCategory = (EditText)updateView.findViewById(R.id.update_category); updateCategory.setText(category[i],EditText.BufferType.NORMAL); ad.setMessage("メッセージ"); ad.setPositiveButton("OK",new DialogInterface.OnClickListener() { public void onClick(DialogInterface di,int which_button) { //OKボタン処理 } }); ad.setNegativeButton("NG",new DialogInterface.OnClickListener() { public void onClick(DialogInterface di,int which_button) { //NGボタン処理 } }); ad.create(); ad.show();