安卓整蛊游戏 源码

package ytu.it.a201758501137.widgetdemo;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class DialogActivity extends AppCompatActivity {
Button zhenggubutton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);

        zhenggubutton= (Button) findViewById(R.id.zhenggubutton);
        zhenggubutton.setOnClickListener(new DialogClick());
    }
    class DialogClick implements View.OnClickListener{
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.zhenggubutton:
                    AlertDialog.Builder dlg1=new AlertDialog.Builder(DialogActivity.this);
                    dlg1.setTitle("你被整蛊了!").setMessage("你是猪吗?").setIcon(R.drawable.xiao).setPositiveButton("我是猪", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            final String []array=new String[]{"确定","确定"};
                            AlertDialog.Builder dlg2= new AlertDialog.Builder(DialogActivity.this);
                            dlg2.setTitle("你居然是猪!").setItems(array, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    final String []array1=new String[]{"YES","YES"};
                                    AlertDialog.Builder dlg3= new AlertDialog.Builder(DialogActivity.this);
                                    dlg3.setTitle("你居然真的是猪!!").setSingleChoiceItems(array1, 0, new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            final String []array2=new String[]{"吃饭","吃饭","还是吃饭","我只会吃"};
                                            final boolean[] ischecked=new boolean[]{false,false,false,false};
                                            AlertDialog.Builder dlg4= new AlertDialog.Builder(DialogActivity.this);
                                            dlg4.setTitle("作为一只猪你的爱好是什么?").setMultiChoiceItems(array2, ischecked, new DialogInterface.OnMultiChoiceClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i, boolean b) {
                                                    if(ischecked[0]==true&&ischecked[1]==true&&ischecked[2]==true&&ischecked[3]==true){
                                                        View dlgview= LayoutInflater.from(DialogActivity.this).inflate(R.layout.layout_dlg,null);
                                                        AlertDialog.Builder dlg5= new AlertDialog.Builder(DialogActivity.this);
                                                        dlg5.setTitle("恭喜你已经承认你是一只猪!").setView(dlgview).show();

                                                        Button pigbutton1,pigbutton2;
                                                        pigbutton1= (Button) dlgview.findViewById(R.id.pigbutton1);
                                                        pigbutton2= (Button) dlgview.findViewById(R.id.pigbutton2);
                                                        pigbutton1.setOnClickListener(new View.OnClickListener() {
                                                            @Override
                                                            public void onClick(View view) {
                                                                Toast.makeText(DialogActivity.this,"你不服也得服!",Toast.LENGTH_SHORT).show();
                                                            }
                                                        });
                                                        pigbutton2.setOnClickListener(new View.OnClickListener() {
                                                            @Override
                                                            public void onClick(View view) {
                                                                Intent intent;
                                                                intent=new Intent(DialogActivity.this,MainActivity.class);
                                                                startActivity(intent);
                                                                Toast.makeText(DialogActivity.this,"这还差不多!",Toast.LENGTH_SHORT).show();
                                                            }
                                                        });

                                                    }

                                                }
                                            }).show();
                                        }
                                    }).show();

                                }
                            }).setCancelable(false).show();
                        }
                    }).setNegativeButton("我不是猪", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            AlertDialog.Builder dlg1=new AlertDialog.Builder(DialogActivity.this);
                            dlg1.setTitle("你被整蛊了!").setMessage("你是猪吗?").setIcon(R.drawable.xiao).setPositiveButton("我是猪", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    final String []array=new String[]{"确定","确定"};
                                    AlertDialog.Builder dlg2= new AlertDialog.Builder(DialogActivity.this);
                                    dlg2.setTitle("你居然是猪!").setItems(array, new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            final String []array1=new String[]{"YES","YES"};
                                            AlertDialog.Builder dlg3= new AlertDialog.Builder(DialogActivity.this);
                                            dlg3.setTitle("你居然真的是猪!!").setSingleChoiceItems(array1, 0, new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {
                                                    final String []array2=new String[]{"吃饭","吃饭","还是吃饭","我只会吃"};
                                                    final boolean[] ischecked=new boolean[]{false,false,false,false};
                                                    AlertDialog.Builder dlg4= new AlertDialog.Builder(DialogActivity.this);
                                                    dlg4.setTitle("作为一只猪你的爱好是什么?").setMultiChoiceItems(array2, ischecked, new DialogInterface.OnMultiChoiceClickListener() {
                                                        @Override
                                                        public void onClick(DialogInterface dialogInterface, int i, boolean b) {
                                                            if(ischecked[0]==true&&ischecked[1]==true&&ischecked[2]==true&&ischecked[3]==true){
                                                                View dlgview= LayoutInflater.from(DialogActivity.this).inflate(R.layout.layout_dlg,null);
                                                                AlertDialog.Builder dlg5= new AlertDialog.Builder(DialogActivity.this);
                                                                dlg5.setTitle("恭喜你已经承认你是一只猪!").setView(dlgview).show();

                                                                Button pigbutton1,pigbutton2;
                                                                pigbutton1= (Button) dlgview.findViewById(R.id.pigbutton1);
                                                                pigbutton2= (Button) dlgview.findViewById(R.id.pigbutton2);
                                                                pigbutton1.setOnClickListener(new View.OnClickListener() {
                                                                    @Override
                                                                    public void onClick(View view) {
                                                                        Toast.makeText(DialogActivity.this,"你不服也得服!",Toast.LENGTH_SHORT).show();
                                                                    }
                                                                });
                                                                pigbutton2.setOnClickListener(new View.OnClickListener() {
                                                                    @Override
                                                                    public void onClick(View view) {
                                                                        Intent intent;
                                                                        intent=new Intent(DialogActivity.this,MainActivity.class);
                                                                        startActivity(intent);
                                                                        Toast.makeText(DialogActivity.this,"这还差不多!",Toast.LENGTH_SHORT).show();
                                                                    }
                                                                });

                                                            }
                                                        }
                                                    }).show();

                                                }
                                            }).show();

                                        }
                                    }).setCancelable(false).show();
                                }
                            }).setNegativeButton("我不是猪", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                }
                            }).setCancelable(false).show();
                        }
                    }).setCancelable(false).show();
            }
        }
    }
}

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值