title: Show Android custom ProgressBar or ProgressDialog dynamically in any class
body: <p>I am trying to make a custom ProgressBar class, in which I want to display a ProgressBar with image rotation. </p>
  
  <p>What I tried was...</p>
  
  <p><strong>my_progress_indeterminate.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;rotate xmlns:android="http://schemas.android.com/apk/res/android"
      android:drawable="@drawable/spool"
      android:pivotX="50%"
      android:pivotY="50%"
      android:fromDegrees="0"
      android:toDegrees="1080"&gt;
  &lt;/rotate&gt;
  </code></pre>
  
  <p><strong>MyProgress.java</strong></p>
  
  <pre><code>public class MyProgress extends ProgressDialog {
    //private AnimationDrawable animation;
    ProgressBar la;
    public ProgressDialog ctor(Context context) {
      MyProgress dialog = new MyProgress(context);
      dialog.setIndeterminate(true);
      dialog.setIndeterminateDrawable(this.getContext().getResources().getDrawable(R.drawable.my_progress_indeterminate));
      dialog.setCancelable(false);
      return dialog;
    }
  
    public MyProgress(Context context) {
      super(context);
    }
  
    public MyProgress(Context context, int theme) {
      super(context, theme);
    }
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.view_loader);
  
       la = (ProgressBar) findViewById(R.id.animation);
  
  
    }
  
    @Override
    public void show() {
      super.show();
  //show the progressbar which is rotating image
  
    }
  
    @Override
    public void dismiss() {
      super.dismiss();
     //hide the progress which is rotating image
    }
  }
  </code></pre>
  
  <p>In my other class where I want to show progress, I am doing like this :</p>
  
  <pre><code>MyProgress rotateImage;
  protateImage = new MyProgress(getActivity());
  
   protateImage.show(); //for showing 
  
  protateImage.hide(); //for hiding 
  </code></pre>
  
  <p><strong>ViewLoader.xml</strong></p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center"
      android:background="@null"
      &gt;
  
  
      &lt;ProgressBar
          android:id="@+id/animation"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:layout_margin="5dip"
          android:indeterminateDrawable="@drawable/my_progress_indeterminate" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>It works well , but I am unable to see my image rotating ,
  only androids custom progressbar spinning style is shown , with a dialog background. </p>
  
  <p>What I want is to show only my image rotating anywhere in my project by creating an instance of my class and showing progressbar (rotating image ) or hiding it ...</p>
  
  <p>How can I make it correct? any help ...</p>