今天在做progressdialog的时候,百度问题的时候,看到不少人在问,怎么让progressbar不转动,我去,嘛情况?我的现在的就不转,我正想找怎么让他转呢。下面做一下笔记:(我感觉这个也可以当做progressbar不转动的解决方案的。)
1.想让不转:
ProgressDialog mDialog1 = new ProgressDialog(ProgressbarTest2Activity.this, R.style.mcustomprogressdialog);
mDialog1.show();
mDialog1.setContentView(R.layout.customprogressdialog);
customprogressdialog.xml文件里面就是一个imageview,我就不贴代码了。imageview的src是一张图片,这个图片是自己想要显示的图片。
2.想让转,就需要加上几句话
ProgressDialog mDialog1 = new ProgressDialog(ProgressbarTest2Activity.this, R.style.CustomProgressDialog);
mDialog1.show();
mDialog1.setContentView(R.layout.customprogressdialog);
ImageView imageView = (ImageView) mDialog1.findViewById(R.id.loadingImageView);
AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
animationDrawable.start();
xml文件和上面的一样。
注意:
1.show()要写在setcontentview()的上面,不让会报“requestFeature() must be called before adding content”错误。
好了,笔记完毕!!