开发者

Is it possible to use phonegap for just a part of the application?

Is开发者_JAVA技巧 it possible to use Phonegap for only a part of an application ?

For instance on Android (but my question includes other OS as well), can an Activity use Phonegap components and native components (in the same screen) ?

Thank you.


The little experience below seem to answer my needs, at least on Android. I guess a similar hack can be made on the other OS.

public class TestPhonegapActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        loadUrl("file:///android_asset/www/index.html");

        LinearLayout linearLayout = new LinearLayout(this);
        ((ViewGroup) appView.getParent()).removeView(appView);
        linearLayout.addView(appView);

        TextView textView = new TextView(this);
        textView.setText("Native");
        linearLayout.addView(textView);

        setContentView(linearLayout);
    }
}


You can simply use :

LinearLayout layout = super.root;

and then add what you want:

TextView textView = new TextView(this);
textView.setText("Native");
linearLayout.addView(textView);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜