Skip to content Skip to sidebar Skip to footer

Forced Close After Adding Custom Imageview

I'm trying to add a custom ImageView to my main.xml, but if I start the program it closes with a forced close. XML:

Solution 1:

Debugger is useless if you haven't attached the source code of Android. Moreover... it's more useful to provide the logcat output. Anyway, I think you are missing one of the constructors. Try this:

public class CustomImageView extends ImageView {

 public CustomImageView(Context context) {
  super(context);
  // TODO Auto-generated constructor stub
 }

 public CustomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
 }
 // rest of your code....

Post a Comment for "Forced Close After Adding Custom Imageview"