obtainStyledAttributes(int[]) is undefined

二月 4th, 2012 没有评论 »

为了防止这个错误“The method obtainStyledAttributes(int[]) is undefined for the type ImageAdapter”,意思是obtainStyledAttributes()是Context类中的方法,如果将ImageAdapter单独写在一个.java文件中的话,必须在obtainStyledAttributes()方法前加上方法的引用才能解决问题

出错之前:obtainStyledAttributes(R.styleable.Gallery)

改后:mContext.obtainStyledAttributes(R.styleable.Gallery)

其中  mContext 要定义

private Context mContext;

mContext = context;