I must edit a software that have a custom view, when I try to edit layout xml, Eclipse says me:
Use View.isInEditMode() in your custom views to skip
Try this it work for me
public class MyOwnTextView extends TextView {
public MyOwnTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
isInEditMode();
}
public MyOwnTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
isInEditMode();
}
public MyOwnTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
isInEditMode();
}
public void setTypeface(Typeface tf, int style) {
if(!this.isInEditMode()){
Typeface normalTypeface = Typeface.createFromAsset(getContext().getAssets(), "font/Roboto-Light.ttf");
Typeface boldTypeface = Typeface.createFromAsset(getContext().getAssets(), "font/Roboto-Light.ttf");
if (style == Typeface.BOLD) {
super.setTypeface(boldTypeface/*, -1*/);
} else {
super.setTypeface(normalTypeface/*, -1*/);
}
}
}
}
then at the xml