ViewPager.OnLongClickListener没有触发

时间:2014-08-12 14:27:13

标签: android android-viewpager onlongclicklistener

我想在用户在视图寻呼机上长按一下时创建一个菜单,但是监听器不会触发。 这是我的代码:

private void setListener() {
        this.mViewPager.setOnLongClickListener(new AlertDialogDisplayer());
    }


private class AlertDialogDisplayer implements OnLongClickListener, android.content.DialogInterface.OnClickListener {

        private final String[] items = {"Start Slideshow from Beginning", "Start Slideshow from here"};

        @Override
        public boolean onLongClick(View arg0) {
            AlertDialog.Builder builder = new AlertDialog.Builder(mViewPager.getContext());
            builder.setTitle("Select an action");
            builder.setItems(items, this);

            AlertDialog alert = builder.create();
            alert.show();
            return true;
        }

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            beginSlideshow(arg1);
        }

beginSlideshow(arg1)应该从头开始播放幻灯片,或者是用户实际所在的图片。

提前感谢您的帮助。

0 个答案:

没有答案