手机直播源码,Android 简单的弹框
手机直播源码,Android 简单的弹框
private static String[] items = new String[]{
"拍照",
"从相册中选择",
};
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setTitle("请选择事件")//设置对话框 标题
.setItems(items, new DialogInterface.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onClick(DialogInterface dialog, int which) {
if(which==0){
Log.e("TAG","事件一--------------------");
}
else{
Log.e("TAG","事件二--------------------");
}
return;
}
});
builder.create()
.show();
AlertDialog alertDialog2 = new AlertDialog.Builder(this)
.setTitle("这是标题")
.setMessage("有多个按钮")
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {//添加"Yes"按钮
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(AlertDialogActivity.this, "这是确定按钮", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {//添加取消
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(AlertDialogActivity.this, "这是取消按钮", Toast.LENGTH_SHORT).show();
}
})
.setNeutralButton("普通按钮", new DialogInterface.OnClickListener() {//添加普通按钮
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(AlertDialogActivity.this, "这是普通按钮按钮", Toast.LENGTH_SHORT).show();
}
})
.create();
alertDialog2.show();
以上就是 手机直播源码,Android 简单的弹框,更多内容欢迎关注之后的文章