<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                為了實現左右翻頁的效果,使用了ViewPager,它會很方便的實現左右滑動后翻頁。 這時需要自己也加上兩個button來實現同樣的操作,如何實現呢?網上一篇blog幫了忙啦。 [【Android】按鈕控制ViewPager的左右翻頁,保留原有的動畫效果](http://blog.sina.com.cn/s/blog_4b20ae2e0101fkpz.html) ViewPager的一個公共方法arrowScroll,查看代碼我們可以有兩個重要的發現: ~~~ public?boolean?executeKeyEvent(KeyEvent?event)?{?? ????boolean?handled?=?false;?? ????if?(event.getAction()?==?KeyEvent.ACTION_DOWN)?{?? ????????switch?(event.getKeyCode())?{?? ????????????case?KeyEvent.KEYCODE_DPAD_LEFT://鍵盤方向鍵左鍵的控制,向左翻頁?? ????????????????handled?=?arrowScroll(FOCUS_LEFT);//FOCUS_LEFT:17?? ????????????????break;?? ????????????case?KeyEvent.KEYCODE_DPAD_RIGHT://右鍵?? ????????????????handled?=?arrowScroll(FOCUS_RIGHT);//FOCUS_RIGHT:66?? ????????????????break;?? ????????????case?KeyEvent.KEYCODE_TAB:?? ????????????????if?(Build.VERSION.SDK_INT?>=?11)?{?? ????????????????????//?The?focus?finder?had?a?bug?handling?FOCUS_FORWARD?and?FOCUS_BACKWARD?? ????????????????????//?before?Android?3.0.?Ignore?the?tab?key?on?those?devices.?? ????????????????????if?(KeyEventCompat.hasNoModifiers(event))?{?? ????????????????????????handled?=?arrowScroll(FOCUS_FORWARD);//FOCUS_FORWARD:2?? ????????????????????}?else?if?(KeyEventCompat.hasModifiers(event,?KeyEvent.META_SHIFT_ON))?{?? ????????????????????????handled?=?arrowScroll(FOCUS_BACKWARD);//FOCUS_BACKWARD:1?? ????????????????????}?? ????????????????}?? ????????????????break;?? ????????}?? ????}?? ????return?handled;?? }?? ~~~ ~~~ public?boolean?arrowScroll(int?direction)?{?? ????View?currentFocused?=?findFocus();?? ????if?(currentFocused?==?this)?currentFocused?=?null;?? ?? ????boolean?handled?=?false;?? ?? ????View?nextFocused?=?FocusFinder.getInstance().findNextFocus(this,?currentFocused,?? ????????????direction);?? ????if?(nextFocused?!=?null?&&?nextFocused?!=?currentFocused)?{?? ????????if?(direction?==?View.FOCUS_LEFT)?{?? ????????????//?If?there?is?nothing?to?the?left,?or?this?is?causing?us?to?? ????????????//?jump?to?the?right,?then?what?we?really?want?to?do?is?page?left.?? ????????????final?int?nextLeft?=?getChildRectInPagerCoordinates(mTempRect,?nextFocused).left;?? ????????????final?int?currLeft?=?getChildRectInPagerCoordinates(mTempRect,?currentFocused).left;?? ????????????if?(currentFocused?!=?null?&&?nextLeft?>=?currLeft)?{?? ????????????????handled?=?pageLeft();?? ????????????}?else?{?? ????????????????handled?=?nextFocused.requestFocus();?? ????????????}?? ????????}?else?if?(direction?==?View.FOCUS_RIGHT)?{?? ????????????//?If?there?is?nothing?to?the?right,?or?this?is?causing?us?to?? ????????????//?jump?to?the?left,?then?what?we?really?want?to?do?is?page?right.?? ????????????final?int?nextLeft?=?getChildRectInPagerCoordinates(mTempRect,?nextFocused).left;?? ????????????final?int?currLeft?=?getChildRectInPagerCoordinates(mTempRect,?currentFocused).left;?? ????????????if?(currentFocused?!=?null?&&?nextLeft? ????????????????handled?=?pageRight();?? ????????????}?else?{?? ????????????????handled?=?nextFocused.requestFocus();?? ????????????}?? ????????}?? ????}?else?if?(direction?==?FOCUS_LEFT?||?direction?==?FOCUS_BACKWARD)?{//17?or?1?? ????????//?Trying?to?move?left?and?nothing?there;?try?to?page.?? ????????handled?=?pageLeft();?? ????}?else?if?(direction?==?FOCUS_RIGHT?||?direction?==?FOCUS_FORWARD)?{//66?or?2?? ????????//?Trying?to?move?right?and?nothing?there;?try?to?page.?? ????????handled?=?pageRight();?? ????}?? ????if?(handled)?{?? ????????playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));?? ????}?? ????return?handled;?? }?? ~~~ 也就是說,我們調用arrowScroll方法用參數1或者17就可以實現向左翻頁;參數2或66就可以實現向右翻頁。 后記: 當你的UI中有EditText這種獲得focus的widget時,則必須用17和66,否則要報錯。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看