Gallery - Scrolling on the touch screen does not work

I have a problem with the Gallery. I can not scroll the touch. Scrolling through DPAD or trackball works fine.

Here is the code: xml Layout:

<?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> 

Adapter:

 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; } } 

I am testing the application on my Android 2.2. Any ideas?

+4
source share
1 answer

Well, just for everyone else that ran into the problem: he installed an onclick listener on my image. it was a problem. You must use the onitemclicklistener gallery. I think that the onclick listener on the view itself somehow absorbs the touch event, and it never hits the gallery ...

+6
source

All Articles