问题
I am developing application with CordovaWebView and i have added the below code in web_view.xml file.
<org.apache.cordova.CordovaWebView
android:id="@+id/cordovaWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
I have implemented methods from CordovaInterface. Now my design page showing the following error message.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
Could anyone please tell me that how to resolve it?
回答1:
isInEditMode()
should be used inside the Custom View constructor. Try the following code:
public class GraphView extends View implements Grapher
{
public GraphView(Context context, AttributeSet attrs) {
super(context, attrs);
if(!isInEditMode())
init(context);
}
public GraphView(Context context) {
super(context);
if(!isInEditMode()){
touchHandler = new TouchHandler(this);
init(context);
}
}
Replace GraphView with your CordovaWebview.
View.isInEditMode()
Indicates whether this View is currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if this View is being drawn by a visual user interface builder, this method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might interfere with the host environment. For instance: the class spawns a thread in its constructor, the drawing code relies on device-specific features, etc. This method is usually checked in the drawing code of custom widgets.
来源:https://stackoverflow.com/questions/30116192/use-view-isineditmode-in-your-custom-views-with-cordovawebview