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();
}
}