图库 - 通过触摸滚动不起作用

时间:2010-10-17 12:01:21

标签: android

我的画廊有问题。我不能通过触摸滚动。通过DPAD或轨迹球滚动工作正常。

这是一些代码: xml布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent" android:gravity="center_vertical">
 <Gallery android:id="@+id/Gallery_Main" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:spacing="10dip"
  android:unselectedAlpha="0.7" />
</LinearLayout>

适配器:

package de.goddchen.android.advent.template;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class AdventAdapter extends BaseAdapter {

 @Override
 public int getCount() {
  return 24;
 }

 @Override
 public Object getItem(int arg0) {
  return arg0;
 }

 @Override
 public long getItemId(int arg0) {
  return arg0;
 }

 @Override
 public View getView(int arg0, View arg1, ViewGroup arg2) {
  MyImageView aiv = (MyImageView) LayoutInflater.from(
    arg2.getContext()).inflate(R.layout.galleryimage, arg2, false);
  aiv.number = arg0 + 1;
  return aiv;
 }
}

我在Android 2.2手机上测试应用程序。 有什么想法吗?

1 个答案:

答案 0 :(得分:6)

好的,只为遇到问题的其他人: 它在我的imageview上设置了一个onclick监听器。那就是问题所在。你必须使用画廊onitemclicklistener。我认为视图本身的onclick监听器会以某种方式消耗触摸事件,而且它永远不会进入画廊......