在Android ListView项目尝试逐个滚动它们时跳跃?

时间:2013-11-07 09:55:53

标签: android

我有15-20全屏图像,我正试图在listview中逐个加载它们。我能够做到这一点,但我的问题是,当我试图滚动到下一个项目时,就像跳到下一个项目不顺利滚动下面是我的代码请建议我做错了。

mArticleContainer.setOnScrollListener(new OnScrollListener() {

            int i = 0;
            int Pre = 0;
            int NumberOfPages = 0;
            boolean touchstate = false;

            @Override
            public void onScrollStateChanged(AbsListView arg0, int arg1) {

                arg0.setOnTouchListener(new OnTouchListener() {
                    @Override
                    public boolean onTouch(View arg0, MotionEvent ev) {

                        Log.i("MAgazineDetailActivity", "list touch activated");
                        String s = ev.getAction() + "";
                        if (s.equalsIgnoreCase("1")) {
                            touchstate = false;
                            int a = (int) ev.getY();
                            if (Pre > a) {
                                i++;
                                if (i >= NumberOfPages) {
                                    i = NumberOfPages - 1;
                                }
                                Log.e("Message---", "" + i + " Pre---" + Pre);
                                mArticleContainer.setSelection(i);
//                              removeView(i - 1);
                            } else if (Pre < ev.getY()) {
                                // i--;
                                if (i < 0)
                                    i = 0;
                                Log.e("Message", "" + i + " Pre---" + Pre);
//                              removeView(i + 1);
                                mArticleContainer.setSelection(i);
                            } else
                                mArticleContainer.setSelection(i);
                            ev.setAction(MotionEvent.ACTION_CANCEL);
                            return false;

                        } else if (s.equalsIgnoreCase("2")) {
                            if (!touchstate) {
                                Pre = (int) ev.getY();
                                touchstate = true;
                            }
                        } else if (s.equalsIgnoreCase("0")) {

                        }

                        return false;
                    }
                });
            }

            @Override
            public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
                i = arg1;
                NumberOfPages = arg3;
            }
        });

谢谢..

0 个答案:

没有答案