Android - 图库在更改子视图的可见性时捕捉

时间:2011-11-09 01:29:54

标签: android android-gallery

我有一个画廊,我已将箭头指示器放在上面。

  <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/black"
    android:layout_weight="1" >
      <com.package.views.MyGallery
        android:id="@+id/carGallery"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:spacing="2dip"
        android:fadingEdge="none" />
      <ImageView
        android:id="@+id/prev"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:src="@drawable/left_orange_arrow"
        android:paddingLeft="25dip" />
      <ImageView
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/right_orange_arrow"
        android:paddingRight="25dip" />
  </RelativeLayout>

当所选项目发生变化时,我会更新箭头:

carGallery.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override
    public void onItemSelected(AdapterView<?> adapter, View view, final int position, long id) {
        Car car = carAdapter.getCar(position);
        top.setText(car.nickname);
        bottom.setText(car.year+" "+car.make+" "+car.model);

        if(carAdapter.getItems().size() == 1) {
            prev.setVisibility(View.GONE);
            next.setVisibility(View.GONE);
        }
        else if(position == 0) {
            prev.setVisibility(View.GONE);
            next.setVisibility(View.VISIBLE);
        }
        else if(position == carAdapter.getItems().size()-1) {
            prev.setVisibility(View.VISIBLE);
            next.setVisibility(View.GONE);
        }
        else {
            prev.setVisibility(View.VISIBLE);
            next.setVisibility(View.VISIBLE);
        }
    }
});

问题: 每次我更新箭头的可见性时,图库都会捕捉到所选图像,使滚动非常紧张。我不是在任何地方调用BaseAdapter.notifyDataSetChanged()。谁能解释一下这个问题?

0 个答案:

没有答案