通常の進行中のアニメーションダイアログではなく、カスタムアニメーションをダイアログに表示したい。
以下は私のレイアウトXMLファイルです。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/blankImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@anim/loading_anim"/>
</LinearLayout>
DialogのonShowListenerで、私は次のように呼び出しました。
dialog.setOnShowListener(new DialogInterface.OnShowListener(){
@Override
public void onShow(DialogInterface dialog) {
final ImageView imageView = (ImageView) dlg.findViewById(R.id.blankImageView);
final AnimationDrawable yourAnimation = (AnimationDrawable) imageView.getBackground();
yourAnimation.start();
}
});
ご覧のとおり、OnShowListenerのダイアログの後にアニメーションを開始しました。ダイアログのonStart()、onCreate()メソッドなどの他のメソッドでアニメーションを開始すると、AnimationDrawableがウィンドウにアタッチされていないため、アニメーションが機能しません。
しかし、onShowListenerインターフェースはAPIレベル8のものです。私の質問は、APIレベル8より前に、AnimationDrawableがウィンドウにアタッチされているかどうかを知る方法はありますか?