我想實現一個代碼,我需要添加ViewPager
進度條,對於每一個尋呼機進度條顯示,直到圖像將不會加載。有關詳細信息,您可以檢查此鏈接Link 有一個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>
public class SlidingImage_Adapter extends PagerAdapter {
private ArrayList<String> IMAGES;
private LayoutInflater layoutInflater;
private Context context;
ProgressBar progressBar;
private ImageLoader imageLoader;
public SlidingImage_Adapter(Context context, ArrayList<String> IMAGES) {
this.context = context;
this.IMAGES=IMAGES;
for(int i=0;i<IMAGES.size();i++)
layoutInflater = LayoutInflater.from(context);
}
@Override
public Object instantiateItem(ViewGroup view, int position) {
// ImageView imageLayout = (ImageView) inflater.inflate(R.layout.screen_slide_fragment, view, false);
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item_view = layoutInflater.inflate(R.layout.screen_slide_fragment, view, false);
ImageView imageView = (ImageView) item_view.findViewById(R.id.image);
Log.e("instantiateItem: ",IMAGES.get(position));
Picasso.with(context)
.load(IMAGES.get(position))
.placeholder(R.drawable.loader_image)
.into(imageView);
return item_view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return IMAGES.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
}
@Override
public Parcelable saveState(){
return null;
}
}
謝謝
您可以使用滑行@Vikas Godiyal –
達到你所使用的滑行意思? –
在ViewPager通過除了在同一時間使頁面加載時默認刷到明年你就無法看到進度條 –