0

ダイアログを次のようにカスタマイズします。

dialoge3 = new Dialog(this);

dialoge3.setContentView(R.layout.layoutdialoge003);

Button btnCacnel = (Button) dialoge3.findViewById(R.id.btnE3Cancel);

btnCacnel.setOnClickListener(new OnClickListener() {    
    public void onClick(View v) {
        // TODO Auto-generated method stub
        dialoge3.cancel();
    }
});

dialoge3.show();

[ダイアログを表示] をクリックしても、アクティビティをクリックできます。ダイアログが表示されているときに、アクティビティをクリックできないようにしたい。

同じ C# の場合:

Form frm=new Form ();
frm.showDialog();
4

4 に答える 4

1

以下の属性を追加してみてください。多分それはあなたが探しているものです、

dialoge3.setCanceledOnTouchOutside(false);

これにより、ユーザーがダイアログの境界外の画面に触れたときに、ダイアログがキャンセルされないようにすることができます。

于 2012-10-09T10:03:37.060 に答える
0
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dialog_fire_missiles)
               .setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       // FIRE ZE MISSILES!
                   }
               })
               .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       // User cancelled the dialog
                   }
               });
        // Create the AlertDialog object and return it
        return builder.create();

これはアラートdailog..ndを作成する簡単な方法です。私のコードを理解していない場合は、breiefでの正確な問題を教えてください。

于 2012-10-09T10:06:48.270 に答える
0

AlertDialog.Builder目的に合わせて使ってみてください。bulder を使用して、ダイアログのカスタム レイアウトを設定することができます。

http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout

于 2012-10-09T10:03:09.537 に答える
0

この機能を使用して、レイアウト ファイルを変更します。

private void showDiaalog() {
                final Dialog dialog = new Dialog(Context);
                dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.layoutfile);

                dialog.setCancelable(true);
                btnok = (Button) dialog.findViewById(R.id.btnOk);

                btnok.setOnClickListener(new OnClickListener() {

                    public void onClick(View arg0) {

                            //some thing else
                        }


                    }
                });
                Button btnCancel = (Button) dialog.findViewById(R.id.btncancel);

                btnCancel.setOnClickListener(new OnClickListener() {

                    public void onClick(View arg0) {

                        dialog.dismiss();
                    }
                });

                dialog.show();
            }
于 2012-10-09T10:20:44.683 に答える