1. <legend id='LAtBc'><style id='LAtBc'><dir id='LAtBc'><q id='LAtBc'></q></dir></style></legend>

      <small id='LAtBc'></small><noframes id='LAtBc'>

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

      如何在视图寻呼机中自动更改图像,当它到达最后一张图像时,它应该自动到达第一张图像

      how to change the image automatically in view pager when it reaches the last image it should come to the first image automatically(如何在视图寻呼机中自动更改图像,当它到达最后一张图像时,它应该自动到达第一张图像) - IT屋-程序员软件开发技术分
        <legend id='LDcWC'><style id='LDcWC'><dir id='LDcWC'><q id='LDcWC'></q></dir></style></legend>
        <tfoot id='LDcWC'></tfoot>
          1. <i id='LDcWC'><tr id='LDcWC'><dt id='LDcWC'><q id='LDcWC'><span id='LDcWC'><b id='LDcWC'><form id='LDcWC'><ins id='LDcWC'></ins><ul id='LDcWC'></ul><sub id='LDcWC'></sub></form><legend id='LDcWC'></legend><bdo id='LDcWC'><pre id='LDcWC'><center id='LDcWC'></center></pre></bdo></b><th id='LDcWC'></th></span></q></dt></tr></i><div id='LDcWC'><tfoot id='LDcWC'></tfoot><dl id='LDcWC'><fieldset id='LDcWC'></fieldset></dl></div>
              <bdo id='LDcWC'></bdo><ul id='LDcWC'></ul>
                <tbody id='LDcWC'></tbody>

              1. <small id='LDcWC'></small><noframes id='LDcWC'>

                本文介绍了如何在视图寻呼机中自动更改图像,当它到达最后一张图像时,它应该自动到达第一张图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我现在正在实现视图寻呼机,我想在特定的时间段内不断地自动更改图像,可能是每 5 毫秒一次.

                I am now implementing the view pager and i want to continuously change the image one by one automatically for a particular periods of time may be once in 5 ms .

                我还必须手动允许用户滑动图像(它工作正常)

                I also have to manually allow the user to swipe the images (it is working properly)

                但图像不会自动改变,当它到达最后一张图像时,它应该自动到达第一张图像

                But the image is not automatically changing and when it reaches the last image it should come to the first image automatically

                final Handler handler = new Handler();
                        final Runnable Update = new Runnable() {
                            public void run() {
                                if (currentPage == strImages.length-1) {
                                    currentPage = 0;
                                }
                                intro_images.setCurrentItem(currentPage++, true);
                            }
                        };
                
                        timer = new Timer(); // This will create a new Thread
                        timer .schedule(new TimerTask() { // task to be scheduled
                
                            @Override
                            public void run() {
                                handler.post(Update);
                            }
                        }, 500, 3000);
                

                我使用了上面的代码,但它不能正常工作

                I used above code but it does not work properly

                推荐答案

                试试这个添加 addOnPageChangeListener 到你的 viewPager 像这样

                try this add addOnPageChangeListener to your viewPager like this

                        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                        @Override
                        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                            if (position == strImages.length-1) {
                                currentPage = 0;
                            }
                            intro_images.setCurrentItem(currentPage++, true);
                        }
                
                        @Override
                        public void onPageSelected(int position) {
                
                        }
                
                        @Override
                        public void onPageScrollStateChanged(int state) {
                
                        }
                    });
                

                或者对于自动更改页面,试试这个创建一个像这样的时间任务

                Timer timer;
                timer = new Timer();
                timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/
                
                 private class RemindTask extends TimerTask {
                int current = viewPager.getCurrentItem();
                
                @Override
                public void run() {
                    runOnUiThread(new Runnable() {
                        public void run() {
                
                           if (current < strImages.size()) {
                                    viewPager.setCurrentItem(current);
                                    current += 1;
                                } else {
                
                                    current = 0;
                                    viewPager.setCurrentItem(current);
                
                                }
                        }
                    });
                
                }
                }
                

                这篇关于如何在视图寻呼机中自动更改图像,当它到达最后一张图像时,它应该自动到达第一张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Android- listview, service mediaplayer, and boolean flags(Android-listview、服务媒体播放器和布尔标志)
                SharedPreferences amp; boolean(SharedPreferences amp;布尔值)
                What values should I use for iOS boolean states?(我应该为 iOS 布尔状态使用什么值?)
                Converting Int to Bool(将 Int 转换为 Bool)
                How do I get NSJSONSerialization to output a boolean as true or false?(如何让 NSJSONSerialization 将布尔值输出为真或假?)
                Is there any difference between bool, Boolean, and BOOL in Objective-C?(Objective-C 中的 bool、Boolean 和 BOOL 之间有什么区别吗?)

                <tfoot id='nqsU0'></tfoot>
                • <bdo id='nqsU0'></bdo><ul id='nqsU0'></ul>

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

                • <small id='nqsU0'></small><noframes id='nqsU0'>

                    • <legend id='nqsU0'><style id='nqsU0'><dir id='nqsU0'><q id='nqsU0'></q></dir></style></legend>