• <bdo id='NDGT4'></bdo><ul id='NDGT4'></ul>
    <legend id='NDGT4'><style id='NDGT4'><dir id='NDGT4'><q id='NDGT4'></q></dir></style></legend>
    <i id='NDGT4'><tr id='NDGT4'><dt id='NDGT4'><q id='NDGT4'><span id='NDGT4'><b id='NDGT4'><form id='NDGT4'><ins id='NDGT4'></ins><ul id='NDGT4'></ul><sub id='NDGT4'></sub></form><legend id='NDGT4'></legend><bdo id='NDGT4'><pre id='NDGT4'><center id='NDGT4'></center></pre></bdo></b><th id='NDGT4'></th></span></q></dt></tr></i><div id='NDGT4'><tfoot id='NDGT4'></tfoot><dl id='NDGT4'><fieldset id='NDGT4'></fieldset></dl></div>

        <tfoot id='NDGT4'></tfoot>
      1. <small id='NDGT4'></small><noframes id='NDGT4'>

      2. 如何在 Android 中向 ViewPager 添加进度条

        时间:2023-10-04
        <i id='7iAC1'><tr id='7iAC1'><dt id='7iAC1'><q id='7iAC1'><span id='7iAC1'><b id='7iAC1'><form id='7iAC1'><ins id='7iAC1'></ins><ul id='7iAC1'></ul><sub id='7iAC1'></sub></form><legend id='7iAC1'></legend><bdo id='7iAC1'><pre id='7iAC1'><center id='7iAC1'></center></pre></bdo></b><th id='7iAC1'></th></span></q></dt></tr></i><div id='7iAC1'><tfoot id='7iAC1'></tfoot><dl id='7iAC1'><fieldset id='7iAC1'></fieldset></dl></div>
          <legend id='7iAC1'><style id='7iAC1'><dir id='7iAC1'><q id='7iAC1'></q></dir></style></legend>

              <tbody id='7iAC1'></tbody>

              <bdo id='7iAC1'></bdo><ul id='7iAC1'></ul>

              <small id='7iAC1'></small><noframes id='7iAC1'>

            • <tfoot id='7iAC1'></tfoot>

                1. 本文介绍了如何在 Android 中向 ViewPager 添加进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 Android 中为 ViewPager 添加进度条?

                  How can I add a progress bar to a ViewPager in Android?

                  我的情况是我必须在 ViewPager 中加载 imageURL.当用户滑动页面时,如果 ImageURL 没有加载,我需要显示进度条/正在加载 GIF 图片.

                  My scenario is that I have to load imageURL's in a ViewPager. When the user swipes the pager, if the ImageURL is not loaded I need to show the progress bar/loading GIF image.

                  有可能吗?

                  推荐答案

                  我认为 Satya 正在考虑以下类似的事情.在您的 viewpager 适配器类中,您应该有这个方法:

                  I think Satya was thinking to something like this in the following. In your viewpager adapter class you should have this method:

                  @Override
                              public Object instantiateItem(View collection, final int position) {
                  
                                  LayoutInflater inflater = (LayoutInflater) collection.getContext()
                                          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  
                  
                                  final FrameLayout imageLayout = (FrameLayout) inflater.inflate(R.layout.fotopager_buttons, null);
                                  final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
                                  final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
                  
                                  imageLoader.displayImage(Gallery.get_big_image_url(position), imageView, options, new ImageLoadingListener() {
                                      @Override
                                      public void onLoadingStarted() {
                                      spinner.setVisibility(View.VISIBLE);
                                      }
                  
                                      @Override
                                      public void onLoadingFailed() {
                                      spinner.setVisibility(View.GONE);
                                      imageView.setImageResource(android.R.drawable.ic_delete);
                                      }
                  
                                      @Override
                                      public void onLoadingComplete() {
                                      spinner.setVisibility(View.GONE);
                                      }
                                      });
                  
                  
                                  views.put(position, iv);
                  
                                  ((ViewPager) collection).addView(imageLayout,0);
                  
                                  return imageLayout;
                  }
                  

                  还有像这样的 R.layout.fotopager_buttons.xml:

                  And the R.layout.fotopager_buttons.xml like that:

                  <?xml version="1.0" encoding="utf-8"?>
                  

                  <ImageView
                      android:id="@+id/image"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"
                      android:adjustViewBounds="true" />
                  
                  <ProgressBar
                      android:id="@+id/loading"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"/>
                  

                  您可以在此处查看 imageLoader 类的其余部分:https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/UniversalImageLoaderExample/src/com/nostra13/example/universalimageloader/ImagePagerActivity.java

                  You can see the rest of the imageLoader class here: https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/UniversalImageLoaderExample/src/com/nostra13/example/universalimageloader/ImagePagerActivity.java

                  这篇关于如何在 Android 中向 ViewPager 添加进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PagerAdapter 总是返回空白 下一篇:如何在带有 android 的视图寻呼机页面中使用滑动手势?

                  相关文章

                2. <small id='hKZPj'></small><noframes id='hKZPj'>

                  <tfoot id='hKZPj'></tfoot>
                    <bdo id='hKZPj'></bdo><ul id='hKZPj'></ul>

                  1. <i id='hKZPj'><tr id='hKZPj'><dt id='hKZPj'><q id='hKZPj'><span id='hKZPj'><b id='hKZPj'><form id='hKZPj'><ins id='hKZPj'></ins><ul id='hKZPj'></ul><sub id='hKZPj'></sub></form><legend id='hKZPj'></legend><bdo id='hKZPj'><pre id='hKZPj'><center id='hKZPj'></center></pre></bdo></b><th id='hKZPj'></th></span></q></dt></tr></i><div id='hKZPj'><tfoot id='hKZPj'></tfoot><dl id='hKZPj'><fieldset id='hKZPj'></fieldset></dl></div>

                      <legend id='hKZPj'><style id='hKZPj'><dir id='hKZPj'><q id='hKZPj'></q></dir></style></legend>