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();
}
}
}
}
相关文章
- 12-18安卓手机游戏开发软件!花三分钟看完这篇文章你就懂了!附架构师必备技术详解
- 12-18Frida 安卓逆向破解Unity游戏IL2CPP
- 12-18一个简单的安卓游戏内购破解
- 12-18uniapp整包更新和热更新组件升级版 支持vue3 支持打开安卓自带的应用市场和苹果appstore
- 12-18【用PS3手柄在安卓设备上玩游戏系列】谈安卓游戏对手柄的支持
- 12-18安卓(Android)+苹果(Ios)仿微信、陌陌 移动社交APP系统源码,手机IM聊天软件源码,企业即时通讯APP程序源码
- 12-18安卓(Android)+苹果(Ios)仿微信、陌陌 移动社交APP系统源码,手机IM聊天软件源码,企业即时通讯APP程序源码
- 12-18手机版_仿微信 陌陌 安卓版(android)/苹果版(iPhone ios),移动社交APP系统源码,企业即时通讯APP程序源码,手机聊天软件源码,移动聊天APP开发
- 12-18Android例子源码模仿安卓微信、云播雷达扫描动画效果
- 12-18安卓开发 从入门到转业 (五) 拼图游戏