问Gallery配合BaseAdapter,其它一切正常,就是无法执行getView(...){...}
public class GalleryAdapter extends BaseAdapter
{
public int getCount()
{
return count;//这里调试count=1;
}
public Object getItem(int position)
{
return position;//这里调试position=1;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)//http://www.eoeandroid.com/forum.php?mod=viewthread&tid=200168
{
if(convertView == null)
{}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
public class CGallery extends Gallery
{
public CGallery(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY)
{
int keyCode;
if (e2.getX() > e1.getX())//滚动到了最左边
{
keyCode = KeyEvent.KEYCODE_DPAD_LEFT;
}
else//滚动到了最右边
{
keyCode = KeyEvent.KEYCODE_DPAD_RIGHT;
}
onKeyDown(keyCode, null);
return true;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
执行如下代码:
CGallery gr_parent=(CGallery)findViewById(R.id.gallery_parent);
GalleryAdapter ad_parent= new GalleryAdapter(this,catalogListNames,0.5f);
gr_parent.setAdapter(ad_parent);
gr_parent.setSelection(0);
如上执行代码后,一切正常在activity中,gallery可以显示出来,就是不能显示每个子项,
还有不管怎么调试都无法执行到GalleryAdapter的getView去,为什么啊?