1

我可以使用带有图像的图库视图。我有以下 onItemSelected -

public void onItemSelected(
        final AdapterView<?> parent,
        final View view,
        final int index,
        final long id) {



    GalleryAdapter.selected = index ;

      Animation growAnimation = AnimationUtils.loadAnimation(this,
              R.anim.grow_shrink_image);
      view.startAnimation(growAnimation);

     ...
}

它工作正常,当一个项目被点击时,它会移动到中心并运行动画。但问题是,当它向左或向右滚动时,到达中心的项目会自动选择并开始动画。如何禁用此自动选择?

4

1 回答 1

2

我有同样的问题。所以我使用了setCallbackDuringFling()

g是一个对象GalleryView

g.setCallbackDuringFling(false);

g.setOnItemSelectedListener(new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> adapter, View view, int pos,
                    long arg3) {
                // TODO Auto-generated method stub
                Toast.makeText(MyActivity.this,"selected", 1000).show();
                            // here u can apply animation to selected image
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapter) {
                // TODO Auto-generated method stub

            }
        });
于 2013-07-15T08:35:26.887 回答