Android 如何为每个寻呼机在ViewPager上添加进度条
我想实现一个代码,需要在Android 如何为每个寻呼机在ViewPager上添加进度条,android,Android,我想实现一个代码,需要在ViewPager上添加进度条,因为每个页面进度条都会显示,直到图像无法加载为止。有关更多详细信息,请查看此链接 有一个ViewPager,其中图像来自服务器端,加载需要时间。我想添加进度条,直到图像无法加载为止 这是布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:lay
ViewPager
上添加进度条,因为每个页面进度条都会显示,直到图像无法加载为止。有关更多详细信息,请查看此链接
有一个ViewPager
,其中图像来自服务器端,加载需要时间。我想添加进度条,直到图像无法加载为止
这是布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="1dip" >
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:layout_gravity="right|top" />
<ProgressBar android:id="@+id/progressBar"
android:progressDrawable="@drawable/loader_image"
android:layout_width="fill_parent" android:layout_height="8dip"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateOnly="false"
android:max="100">
</ProgressBar>
公共类SlidingImage_适配器扩展了PagerAdapter{
私有数组列表图像;
私人停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场停车场;
私人语境;
ProgressBar ProgressBar;
私有图像加载器;
公共幻灯片图像适配器(上下文、ArrayList图像){
this.context=上下文;
这个。图像=图像;
对于(int i=0;i使用毕加索加载加载程序设置附带的图像
Picasso.with(context)
.load(imageUrl)
.fit()
.error(R.drawable.error_drawable)
.placeholder(R.drawable.loader_image)
.into(imageView);
screen\u slide\u fragment.xml应仅包含ImageView作为根视图。这就是您的方法的外观
@Override
public Object instantiateItem(ViewGroup view, int position) {
ImageView imageLayout = (ImageView) inflater.inflate(R.layout.screen_slide_fragment, view, false);
Picasso.with(context)
.load(IMAGES.get(position))
.placeholder(R.drawable.loader_image)
.into(imageLayout);
return imageLayout;
}
将此添加到应用程序的gradle文件中
compile 'com.squareup.picasso:picasso:2.5.2'
您可以使用glide@Vikas Godiyal实现,默认情况下,除了同时加载页面外,在ViewPager中使用glide是什么意思?因此,当您滑动到下一个页面时,您将无法看到进度barIt必须使用Picasso还有另一种选择,即glide。我应该使用什么来代替网络ImageView@VikasGodiyal正常使用图像视图OK我已将网络图像视图更改为简单图像视图,但ImageView.setImageUrl(IMAGES.get(position),imageLoader);(无法解析方法)上有一个错误
compile 'com.squareup.picasso:picasso:2.5.2'