title: Custom Progress Dialog With Squre Image Rotation With AsynTask
body: <p>I have created a custom Loading Progress Dialog. And its working well.</p>
  
  <p>I am rotating 12 square Images here is one of them</p>
  
  <p><img src="https://i.stack.imgur.com/AfVEM.png" alt="enter image description here"></p>
  
  <p>But when I want to use it with AsynTask, The animation not working.</p>
  
  <p><em>My Sample code is below.</em></p>
  
  <p>Activity Where I Start Loading... Animation and Stop.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>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);
        }
  }
  </code></pre>
  
  <p>XML layout with Simple Text and Image for Progress Dialog.</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;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" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/progress_sm_w01" /&gt;
  
      &lt;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" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Animation List having 12 Images I am Rotating with Angle &amp; Time Duration</p>
  
  <p><strong>progress_animation_white.xml</strong></p>
  
  <pre><code>&lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item android:drawable="@drawable/progress_sm_w01" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w02" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w03" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w04" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w05" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w06" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w07" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w08" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w09" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w10" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w11" android:duration="50" /&gt;
      &lt;item android:drawable="@drawable/progress_sm_w12" android:duration="50" /&gt;
  
      &lt;/animation-list&gt;
  </code></pre>
  
  <p>Here is the result Loading Screen..</p>
  
  <p><img src="https://i.stack.imgur.com/EBJnY.png" alt="enter image description here"></p>
  
  <blockquote>
    <p><strong>My Question is Is there anyway to Achieve the same Loading Animation</strong>
    <strong>with AsynTask.</strong></p>
  </blockquote>
  
  <p>Your Small Help will appreciated.</p>