小编Vip*_*mar的帖子

使用复选框实现对话框

这是我的对话框

 

public class CustomDialogClass extends Dialog implements
 android.view.View.OnClickListener {

     public Activity c;
     public Dialog d;
     public Button no;
     CheckBox yes;
     boolean p;
     public CustomDialogClass(Activity a) {
         super(a);
         // TODO Auto-generated constructor stub
         this.c = a;
     }

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         setContentView(R.layout.custom_dialog);
         yes = (CheckBox) findViewById(R.id.checkBox1);
         no = (Button) findViewById(R.id.btn_no);
         no.setOnClickListener(this);
         yes.setChecked(false);
         yes.setOnClickListener(this);
     }

     @Override
     public void onClick(View v) {
         switch (v.getId()) {
         case R.id.checkBox1:
             yes.setChecked(true);
             break;
         case R.id.btn_no:
             dismiss();
             break;
         default:
             break;
         }
     }
 } …
Run Code Online (Sandbox Code Playgroud)

checkbox android dialog

1
推荐指数
1
解决办法
5052
查看次数

标签 统计

android ×1

checkbox ×1

dialog ×1