java - Android - Unable to extend ImageView -
i want extend imageview:
import android.content.context; import android.util.attributeset; import android.widget.imageview; public class squareimageview extends imageview { public squareimageview(context context) { super(context); } public squareimageview(context context, attributeset attrs) { super(context, attrs); } public squareimageview(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); } @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); int width = getmeasuredwidth(); setmeasureddimension(width, width); } }
but android studio returns compile error:
this custom view should extend android.support.v7.widget.appcompatimageview instead
but importing android.support.v7.widget.appcompatimageview
insted of android.widget.imageview
not solve problem because imageview marked not imported...
what doing wrong here?
this works fine
import android.content.context; import android.support.v7.widget.appcompatimageview; import android.util.attributeset; public class customimageview extends appcompatimageview { public customimageview(context context) { super(context); } public customimageview(context context, attributeset attrs) { super(context, attrs); } public customimageview(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); } }
when import appcompatimageview
have use too. not this, in java, what import use.putting other way, import want use
Comments
Post a Comment