安卓的PhoneGap与本地控件控件、PhoneGap

2023-09-03 21:36:45 作者:晴。或许还有阴雨时﹄

我想建立一个Android应用程序与PhoneGap的。

I am trying to build an Android application with PhoneGap.

我需要能够使用PhoneGap的的WebView(super.appView)及其所有的JavaScript的魔法,但我还需要各地的WebView显示一些原生UI控件。

I need to be able to use the PhoneGap WebView (super.appView) and all of its javascript magic but I also need to display some native UI controls around the WebView.

这后接着部分的方式来提供解决方案Android PhoneGap的插件,用户界面​​的TabBar,调整的WebView

This post goes part way to providing a solution Android PhoneGap Plugin, UI tabbar, resize WebView

有没有人成功地实现PhoneGap的一个原生的UI?

Has anyone managed to implement PhoneGap with a native UI?

我也将使用GestureOverlayView但那是另一回事;)

I will also be using a GestureOverlayView but thats another story ;)

推荐答案

答:

super.onCreate(savedInstanceState);
//creates super.appView and calls setContentView(root) in DroidGap.java
init();
//just an empty LinearLayout
layoutId = R.layout.blank;
view = new LinearLayout(this);
setContentView(layoutId);
view.addView(your_component_here);
view.addView((View) appView.getParent()); //adds the PhoneGap browser at index 1
//accesses the browser at index 1. Tells browser to not fill view
view.getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
setContentView(view);

我会努力告诉你如何工作的,我可以告诉你的是,它确实,这是我自己的工作。

I would struggle to tell you how this works, all I can tell you is that it does and it is all my own work.

视图设置为不同的颜色可以帮助你看到正在发生的事情太多......

Setting the view to a different colour can help you to see what is going on too....

view.setBackgroundColor(Color.BLUE);

与PhoneGap的-1.0.0.jar工作的最新版本为止。

Working with PhoneGap-1.0.0.jar the latest release so far.