我正在从服务器检索数据时显示进度条,然后在图表上显示该数据,但是在绘制图表数据时,我的进度条会冻结,有人知道为什么吗?感谢您的帮助。
我正在使用一个叫做“retrieving data finished”的handler,在获取数据后调用。当点击按钮时,我会获取数据并显示进度条。
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();
}
};
我正在使用一个叫做“retrieving data finished”的handler,在获取数据后调用。当点击按钮时,我会获取数据并显示进度条。
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();
}
});