Note that there are some explanatory texts on larger screens.

plurals
  1. POExtending AdapterView
    primarykey
    data
    text
    <p>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).</p> <p>Actual code is like this:</p> <pre><code> public class MyAdapterView extends AdapterView&lt;ImageAdapter&gt; implements AdapterView.OnItemClickListener{ private ImageAdapter mAdapter; public MyAdapterView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); initThings(); } private void initThings(){ setOnItemClickListener(this); } @Override public ImageAdapter getAdapter() { // TODO Auto-generated method stub return mAdapter; } @Override public void setAdapter(ImageAdapter adapter) { // TODO Auto-generated method stub mAdapter=adapter; requestLayout(); } View obtainView(int position) { View child = mAdapter.getView(position, null, this); return child; } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); for(int i=0;i&lt;mAdapter.getCount();i++){ View child = obtainView(i); child.layout(10, 70*i, 70, 70); addViewInLayout(child, i, null, true); } this.invalidate(); } @Override public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { Log.d("MYEXAMPLES","Clicked an item!"); } } </code></pre> <p>This isn't a coding masterpiece, it just displays a pseudo-listview with pictures. I know i could've used ListView, GridView, Spinner, etc. but i'm relative new to android and i'm trying to figure out some things on it.</p> <p>Well, the question here is: Why is my <B>onItemClick</B> not firing?</p> <p>Using the same ImageAdapter with a GridView, everything works ok, but when i use with above class, i get nothing. Inside <B>AdapterView.java</B> there is code for those click, longclick, etc events... so why can't i just fire them? Maybe i'm misunderstanding basic things on how AdapterView works? Should I extend other base classes instead? And why?</p> <p>Hoping to find more experienced guidance on here, thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload