Question

So I have a TableLayout with TableRows with images in them. After creation, I have to run through the images and put a clicklistener on them. But for some reason that listener is completely ignored. What am I missing (new to android). Ive tried waiting with putting them as contentview, but it makes no difference.

  View vg = tableRow.getChildAt(cell);

                        vg.setOnClickListener(new OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Log.v("clicked", "yeah");
                               clickSquare((ImageView)view); 
                            }
                        });
Was it helpful?

Solution

Did you also make the row clickable?

Consider adding this:

vg.setClickable(true);

OTHER TIPS

I think you are better served just doing this.

myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

    @Override
    void onItemClick(AdapterView<?> parent, View view, int position, long id) {
         // do something cool, notice you have the position and the view.
    }

});

Both ListView and GridView extend AbsListView, and that's where the method comes from.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top