Android 带动画的AlertDialog
我有一个带有动画的AlertDialog,我想给它添加按钮,我该怎么做 以下是我的AlertDialog代码:Android 带动画的AlertDialog,android,android-alertdialog,Android,Android Alertdialog,我有一个带有动画的AlertDialog,我想给它添加按钮,我该怎么做 以下是我的AlertDialog代码: private void openPopUP() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Game Paused"); builder.setMessage("Check out the transition!"); dialog =
private void openPopUP() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Game Paused");
builder.setMessage("Check out the transition!");
dialog = builder.create();
dialog.getWindow().getAttributes().windowAnimations =
R.style.dialog_animation;
dialog.show();
}
以下是我的风格代码:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light"/>
<style name="AppTheme" parent="AppBaseTheme"/>
<style name="dialog_animation">
<item name="android:windowEnterAnimation">@anim/slide_in_left</item>
<item name="android:windowExitAnimation">@anim/slide_out_right</item>
</style>
</resources>
以下是我的动画文件夹文件:
滑入左侧:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p" android:toXDelta="0"
android:duration="500" />
向右滑出:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXDelta="0"
android:toXDelta="100%p" />
我需要在alertdialog中添加3个按钮,如何才能做到?谢谢。您可以使用方法builder.setPositiveButtonString title、DialogInterface.OnClickListener listener、然后是builder.setNeutralButton。。。最后是builder.setNegativeButton