本文介绍了使用CordovaWebView在自定义视图中使用View.isInEditMode()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CordovaWebView开发应用程序,并且已在web_view.xml文件中添加了以下代码.

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" />

我已经实现了CordovaInterface的方法.现在,我的设计页面显示以下错误消息.

I have implemented methods from CordovaInterface. Now my design page showing the following error message.

有人可以告诉我如何解决吗?

Could anyone please tell me that how to resolve it?

推荐答案

isInEditMode()应该在自定义视图构造函数中使用.尝试以下代码:

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);
          }
        }

用CordovaWebview替换GraphView.

Replace GraphView with your CordovaWebview.

View.isInEditMode()

这篇关于使用CordovaWebView在自定义视图中使用View.isInEditMode()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:22