i am showing Progress Bar at time of retrieving data from server and after retrieving data from server showing that data on chart but at time of plotting that data on chart my progress bar get freezes does any one have idea why this is so......
THANKS in advance...
private ProgressDialog pd;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(context, "Please Wait...", Toast.LENGTH_LONG).show();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
functionDrawMyData();/*in this function i am accessing activity view and drawing data on that view at time of drawing my Progress bar Freezes */
}
});
runOnUiThread(t);
pd.dismiss();
}
};
this handler i am using which is called after retrieving data finished
and on button click i am getting data and showing progress bar
ImageButton myButton = (ImageButton) findViewById(R.id.myBtn);
pair1ChartButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
pd = ProgressDialog.show(v.getContext(),"Please wait...","Retrieving data ...",true,
true,
new DialogInterface.OnCancelListener(){
@Override
public void onCancel(DialogInterface dialog) {
}
});
Thread t = new Thread(new Runnable() {
@Override
public void run() {
getDataFromServer();//calling function to get data from server
handler.sendEmptyMessage(0);
}
});
t.start();
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…