I have a DialogFragment
and I set animation for enter/exit in the onActivityCreated
method as below:
@Override
public void on
I think the best approach is to call the different animations on Button click. Hence you would have something similar to the below:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button OkButton = (Button) findViewById(R.id.btnOk);
Button CancelButton = (Button) findViewById(R.id.btnCancel);
OkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
getDialog().getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
}
});
return true;
CancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
getDialog().getWindow().getAttributes().windowAnimations = R.style.DialogAnimation2;
}
});
return true;
}
If I were you, I would also use correct naming conventions for future reference. For example setting DialogAnimation to OkAnimation and DialogAnimation2 to CancelAnimation.
Home this helps :)