tags:

views:

13

answers:

1

Hey everyone, i have problem with a Gallery. I can't scroll via touch. Scrolling via DPAD or trackball works fine. Here is some code: The 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>

The 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 test the app on my Android 2.2 phone. Any ideas?

Greets, Goddchen

A: 

Ok just for everyone else experiencing the problem: it was setting an onclick listener on my imageview. that was the problem. you have to use the gallery onitemclicklistener instead. i think the onclick listener on the view itself somehow consumes the touch event and it never gets to the gallery...

Goddchen