간단한 작업을 수행하고 싶습니다. 대화 상자가 닫히기 전에 논리 (getWindow(). getAttributes(). windowAnimations = ...)에 따라 다른 닫기 애니메이션을 설정하고 싶습니다. 예를 들어, 나는 대화 상자에 2 개의 버튼이 있으며, 첫 번째를 누르면 왼쪽으로 슬라이드하고, 두 번째를 누르면 오른쪽으로 슬라이드합니다. 내가 안드로이드에 대한 몇 가지 애니메이션 스타일 파일을 만들었습니다 : windowExitAnimation 및 android : windowEnterAnimation 그리고 그들은 사용자 정의 대화 상자 생성자에 전달 된 경우 작동합니다. 하지만 나는 다른 애니메이션을 필요로 생성자 접근 방식으로 코드 내에서 windowAnimations를 override 할 수 없다. 어떻게이 코드를 수행 할 수 있으며이 코드가 작동하지 않는 이유는 무엇입니까?런타임시 애니메이션 변경
// close button
_button_close = (ImageButton)findViewById(R.id.buttonClose);
if (_button_close != null)
{
_button_close.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
// set animation
getWindow().getAttributes().windowAnimations = R.style.DialogSlideOutLeft;
// close form
dismiss();
}
}
);
}
이 적용되지 않습니다 나를 위해 – stoefln