PhoneGap的:如何获得appView的ID,并通过它周围? [英] PhoneGap: How do I get appView's id and pass it around?

查看:141
本文介绍了PhoneGap的:如何获得appView的ID,并通过它周围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关PhoneGap的应用程序,为指导说,我已经取代了的setContentView() super.loadUrl(文件行:/// android_asset / WWW / index.html的); 键,下一行是 appView.addJavascriptInterface(新JavaScriptInterface(本),机器人);

我的问题是

  1. 如果我想用appView在我JSInterface,我怎么能找到它,或者把它传递到JSInterface,或者从JSInterface引用它。
  2. ,是PhoneGap的appView唯一的WebView?
解决方案

首先,你不应该添加自己的JS接口的方法。这是更好,如果你写一个PhoneGap的插件:

<一个href="http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android" rel="nofollow">http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android

我们已经通过确保所有的痛苦遭遇JS接口正确的设置。从你的插件,你可以访问appView使用:

  this.webView
 

是的,appView是PhoneGap的唯一的WebView。

For PhoneGap Application, as the instruction said, I have replaced the setContentView() line with super.loadUrl("file:///android_asset/www/index.html"); and the next line is appView.addJavascriptInterface( new JavaScriptInterface(this), "Android");

My question is

  1. if I wanna use appView in my JSInterface, how can I find it, or pass it into JSInterface, or reference it from JSInterface.
  2. And is appView the only webview in PhoneGap?

解决方案

First you should not take the approach of adding your own JS interface. It is better if you write a PhoneGap plugin:

http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android

We've already suffered through all the pains of making sure the JS interfaces are setup correctly. From your plugin you can get access to appView by using:

this.webView

Yes, appView is the only webview in PhoneGap.

这篇关于PhoneGap的:如何获得appView的ID,并通过它周围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆