如何在加载图片时显示进度条。我已经尝试了下面给出的代码
Picasso.with(getActivity())
.load(stage1ImageURL)
.placeholder(android.R.layout.simple_spinner_item)
.error(R.drawable.no_image).into(stage1ImageView);
答案 0 :(得分:0)
答案 1 :(得分:0)
试试这个,它使用AsyncTask
:
public class LoadData extends AsyncTask<Void, Void, Void> {
ProgressDialog progressDialog;
//declare other objects as per your need
@Override
protected void onPreExecute()
{
//show loading dialog
progressDialog= ProgressDialog.show(YourActivity.this, "Progress Dialog Title Text","Process Description Text", true);
//do initialization of required objects objects here
};
@Override
protected Void doInBackground(Void... params)
{
//do loading operation here
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
progressDialog.dismiss();
};
}
您可以使用onCreate()
:
LoadData task = new LoadData();
task.execute();
答案 2 :(得分:0)
你必须使用
progressBar.setVisibility(View.VISIBLE);
显示progressBar。并隐藏它,
progressBar.setVisibility(View.GONE);
关注this link以获取完整代码。