Method undefined for type ImageView
I'm trying to create an ImageView and to set its position without XML.
I've the following code:
public class myClass {
Activity act;
public myClass(Activity act) {
th开发者_如何学Gois.act = act;
}
public void setImage(){
ImageView img = new ImageView(act);
img.setImageResource(R.drawable.myimg);
float xpos = 100;
img.setX(xpos);
}
}
I get the error:
"The method setX(float) is undefined for the type ImageView"
This method is only available since API level 11:
http://developer.android.com/reference/android/view/View.html#setX(float)
Are you sure your coding for this API level?
As ImageView extends View which offers the public Method setX this should work, unless maybe you imported the wrong ImageView. Check your import statement.
精彩评论