0

i am new to android and i am trying to build a customized circular ProgressBar according to network calls..means

1.when i click the Button, the ProgressBar should load 50%

2.when i get response from server, it must load other 50% to complete the action thank you in advance

and here is my Prog.java Class

public class Prog extends Activity {

    private ProgressBar progBar;
    private TextView text;
    private Handler mHandler = new Handler();
    private int mProgressStatus=0;
    int load=0;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_prog);
      progBar= (ProgressBar)findViewById(R.id.progressBar);
      dosomething();

  }

  public void dosomething() {

      new Thread(new Runnable() {
          public void run() {
              final int presentage=0;
              while (mProgressStatus < 50) {
                  mProgressStatus += 1;
                  // Update the progress bar
                  mHandler.post(new Runnable() {
                      public void run() {
                          progBar.setProgress(mProgressStatus);


                      }
                  });
                try {

                    Thread.sleep(50);

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

         }
        }).start();
    }

 }
Baskar P
  • 79
  • 1
  • 2
  • 11
  • ... and what is your problem ? – JimHawkins Aug 09 '16 at 07:05
  • i got 2 Activities in my application 1. first activity contains varify button ..when i clicked that button it calls to server ..in that stage my progress bar should load 50% and when i get response from the server it must load other 50 % of progress Bar.....i really don't know how to implement with the code....so please help – Baskar P Aug 09 '16 at 07:09
  • StackOverflow is not a 'Code this for me'-site. Try tutorials and the like first and then ask questions to more specific problems. – Tom K. Aug 09 '16 at 07:19

1 Answers1

0

below link is working and works on ProgressBar countdown

so you can try this

Community
  • 1
  • 1
  • i am getting exception here........ Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setProgress(int)' on a null object reference – Baskar P Aug 09 '16 at 07:55