Okno dialogowe Custom Progress z rotacją obrazu Squre z AsynTask

Stworzyłem niestandardowe okno dialogowe postępu ładowania. I działa dobrze.

Obracam 12 obrazów kwadratowych tutaj jest jednym z nich

Ale kiedy chcę go używać z AsynTask, animacja nie działa.

Mój przykładowy kod znajduje się poniżej.

Aktywność Gdzie zaczynam Ładowanie ... Animacja i Stop.

MainActivity.java

public class MainActivity extends Activity {
    AnimationDrawable loadingViewAnim;
    TextView loadigText;
    ImageView loadigIcon;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        loadigText = (TextView) findViewById(R.id.textView1);
        loadigText.setText("Loading...");
        loadigText.setVisibility(View.GONE);

        loadigIcon = (ImageView) findViewById(R.id.imageView1);
        loadigIcon.setVisibility(View.GONE);

        loadigIcon.setBackgroundResource(R.anim.progress_animation_white);
        loadingViewAnim = (AnimationDrawable) loadigIcon.getBackground();


    }

    //When User Touch on Screen The Loading... Animation Starts With Image Rotation

    //If I start below code in AsynTask's onPreExecute method it doesn't work
    public boolean onTouchEvent(MotionEvent event)
      {
        loadigText.setVisibility(View.VISIBLE);
        loadigIcon.setVisibility(View.VISIBLE);

          if (event.getAction() == MotionEvent.ACTION_DOWN)
          {
             loadingViewAnim.start();
             return true;
          }
         return super.onTouchEvent(event);
      }
}

Układ XML z oknem dialogowym Prosty tekst i obraz dla postępu.

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/progress_sm_w01" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="Loading..."
        android:textColor="#ffffff"
        android:textSize="12sp" />

</LinearLayout>

Lista animacji z 12 obrazami Obracam z kątem i czasem trwania

progress_animation_white.xml

<animation-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/progress_sm_w01" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w02" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w03" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w04" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w05" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w06" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w07" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w08" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w09" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w10" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w11" android:duration="50" />
    <item android:drawable="@drawable/progress_sm_w12" android:duration="50" />

    </animation-list>

Oto wynik ładowania ekranu ..

Moje pytanie brzmi: Czy mimo to można uzyskać tę samą animację ładowania z AsynTask.

Twoja mała pomoc zostanie doceniona.

questionAnswers(2)

yourAnswerToTheQuestion