天天看點

Android彈窗頁面的三種實作方式

1.AlertDialog設定自定義view

2.自定義Dialog控件

3.PopupWindow

Android彈窗頁面的三種實作方式
Android彈窗頁面的三種實作方式

最簡單的AlertDialog設定view

LayoutInflater inflater = LayoutInflater.from(getApplication());
View view = inflater.inflate(R.layout.dialog_item01, null);
AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this);
builder.setView(view);
AlertDialog dialog=builder.create();
dialog.show();
           

AlertDialog細節:大小和位置的設定,取得内部控件執行個體

https://blog.csdn.net/yh18668197127/article/details/84975023

自定義Dialog步驟請看我的另一篇部落格

https://blog.csdn.net/yh18668197127/article/details/84982630

PopupWindow的用法請看我的另一篇部落格

https://blog.csdn.net/yh18668197127/article/details/84985307