i m 试图(为了学习目的)自己执行简单的调试器,其中物品来自基本调试器(来自 s样本的Image Adapter)。
实际守则就是这样:
public class MyAdapterView extends AdapterView<ImageAdapter> 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<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<?> parent, View v, int position, long id) {
Log.d("MYEXAMPLES","Clicked an item!");
}
}
这只是一个编织的主编,它只是展示了一个带有照片的假名单。 我知道,我可以先使用清单、GridView、Spinner等,但一米与甲状腺和一米的相对照,试图列举其中的一些内容。
Well, the question here is: Why is my onItemClick not firing?
Using the same ImageAdapter with a GridView, everything works ok, but when i use with above class, i get nothing. Inside AdapterView.java 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?
希望事先就此找到更有经验的指导。