AlertDialog
1.基本顯示
2.顯示自定義View
View view=View.inflate(this,R.layout.login_layout,null);
final EditText etEmail=(EditText)view.findViewById(R.id.layout_login_et_email);
final EditText etPwd=(EditText)view.findViewById(R.id.layout_login_et_Passwords);
AlertDialog dialog=new AlertDialog.Builder(MainActivity.this)
.setTitle("Login")
.setView(view)
.setNegativeButton("Cancel", null)
.setPositiveButton("Login",null)
.create();
dialog.setCancelable(false); //點擊Dialog外圍區域,不能夠關閉Dialog
dialog.show();
// 點擊 PositiveButton 按鈕後,不會關閉Dialog
// 注意須要寫在 sho
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});