今天主要的重點會著重在Dialog
| Android | iOS | 
|---|---|
| Button | UIButton | 
| Dialog | UIAlertController | 
 
 
 
 
 
Toast
⚠️⚠️⚠️原生就有提供畫面提示的類別,叫Toast(是長得像吐司嗎?),一行Toast.makeText(this,"登入成功", Toast.LENGTH_LONG).show()就可搞定通知user這件事,讚讚❤️
以前的UIAlertView是用Delegate
後來改UIAlertController用Block/Closure
而Android的Dialog除了採用Closure以外(我不知道在Android叫什麼)
還可以利用Builder做鏈式寫法⚠️⚠️⚠️
一路點下去就是爽~
        Dialog dialog = new AlertDialog.Builder(this)
            .setTitle("請問!")
            .setMessage("現在是白天還是晚上?")
            .setPositiveButton("白天", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Toast.makeText(Lesson06Activity.this,"您選擇的是白天",Toast.LENGTH_LONG).show();
                }
            })
            .setNegativeButton("晚上", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Toast.makeText(Lesson06Activity.this,"您選擇的是晚上",Toast.LENGTH_LONG).show();
                }
            })
            .setNeutralButton("我不知道", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Toast.makeText(Lesson06Activity.this,"那麼我明天再問您一次",Toast.LENGTH_LONG).show();
                }
            }).create();
        dialog.show();
可以看到上面的code,只有請AlertDialog.Builder生一次dialog
就可以.setTitle.setPositiveButton.create.......點下去了
只可惜不了解為什麼不能.create後面接.show?
可以去 https://github.com/mark33699/IDLA 看一下順便給顆⭐️
如果你喜歡我的影片別忘了按讚分享加訂閱,開啟紅色的小鈴鐺,我們明天見~