0

I have a gallery that's loaded via a BaseAdapter. This works fine. I was interested in keeping track of which item in the gallery is clicked. When I add an AdapterOnClickListener, this seems to override the actual gallery click. Meaning, it will break in the click event, but the gallery has lost it's normal functionality (i.e. it doesn't set focus to the item clicked).

Is there a way to keep track of which item in a gallery is clicked?

1
  • yes you have to implement onclick seperately on each item in the adapter itself Mar 22, 2012 at 5:38

2 Answers 2

0

Set on ItemClickListener in gallery object

gallery.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position,
                long arg3) {
            Log.d("LOG","Item selected at position "+position +" in "+currentPosition); 
        }
    });
0
0

Use setTag() when you construct view from adapter. Then use getTag() to find which view is clicked.

1
  • Thanks for the response, this might come in handy elsewhere. Mar 22, 2012 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.