Extending AdapterView

前端 未结 3 455
生来不讨喜
生来不讨喜 2020-12-31 07:08

i\'m trying to make (for learning purposes) my own implementation of a simple AdapterView where items comes from an basic Adapter (ImageAdapter from sdk samples).

Ac

相关标签:
3条回答
  • 2020-12-31 07:53

    I am playing around with something similar and i am using onItem*Selected*Listener which may be more what you are looking for.

    0 讨论(0)
  • 2020-12-31 07:59

    Instead of extending the AdapterView, why dont you try with the baseAdapter. When you costumize your Adapter, it has oen method given below.

    getView(int position, View convertView,ViewGroup group) 
    

    in above method you can access the layout for each list item of the listview and here you can set the all supported events for each control.

    0 讨论(0)
  • 2020-12-31 08:11

    If you take a look into AdapterView's sources, you'll see that the OnItemClickListener gets invoked in a method, called performItemClick:

    public boolean performItemClick(View view, int position, long id) {
        if (mOnItemClickListener != null) {
            // ...
            mOnItemClickListener.onItemClick(this, view, position, id);
            return true;
        }
        return false;
    }
    

    However, if you search the AdapterView source for where this method is used, you'll see that it isn't called anywhere!

    Indeed, if you check the source of the Gallery for example, you'll see that the performItemClick is called within the handling of the onSingleTapUp or onKeyUp events.

    If you want to use that, you have to detect when a user clicks somewhere and call performItemClick on your own.

    0 讨论(0)
提交回复
热议问题