手機直播原始碼,Android 簡單的彈框

zhibo系統開發發表於2023-09-27

手機直播原始碼,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 簡單的彈框,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2986290/,如需轉載,請註明出處,否則將追究法律責任。

相關文章