1

As mentioned in topic. There is Base adapter implementation for GridView where during debug we can see that onItemClick is called with proper values like here:

enter image description here

... and just after this call is getView from BaseAdapter implementation which is called with:

enter image description here

There may be no dependency between these two, but anyway clicking on different elements on GridView should return different position values.

if convertView != null then convertView.getId(); returns -1 .

Any ideas appreciated.

EDIT:

This is from adapter:

  public GridImageAdapter(Context context, ArrayList<TileWidget> tileWidgetList) {
        this.context = context;
        this.tileWidgetList = tileWidgetList;
    }

    @Override
    public int getCount() {
        return tileWidgetList.size();
    }

    @Override
    public Object getItem(int position) {
        TileWidget tw = tileWidgetList.get(position);
        return tw;
    }

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

The value returned by

public long getItemId(int position)

is ok.

EDIT:

Just debugged that is returns good position values when it is initialized. So the zero'es are only onClick results.

Jacob
  • 14,949
  • 19
  • 51
  • 74
  • You have to post the code from the adapter. You're messing with the position index somewhere. – sandalone Oct 25 '14 at 10:29
  • Why would you ever want to call `convertView.getId()`? This will return the `View` resource identifier. That is not the same as calling `BaseAdapter.getItemId(int position)`. – Paul Burke Oct 25 '14 at 11:17
  • It's not used, just checked for bad reason.. Still has no idea what to do. To worked it around and stored this.lastClickedItemsId = position;, when called getItem(int position), but I know It's not a good sollution. – Jacob Oct 25 '14 at 11:20
  • @sandalone, plesae look on update. – Jacob Oct 25 '14 at 11:29
  • i see a lot of place where people implement a custom variable for the data and override methods and rewirte the same code tat android framework already as, when the adapter as one inbuilt.. any specific reasons for tat? – Panther Oct 25 '14 at 12:18
  • Checkout this: http://stackoverflow.com/a/13603323/1680297 it helps me – MMiroslav Feb 11 '15 at 01:51

0 Answers0