就U.I而言,本机活动与SDK活动 [英] Native Activity vs SDK Activity in terms of U.I

查看:133
本文介绍了就U.I而言,本机活动与SDK活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在进行大量研究,甚至还对Android的NDK(而不是SDK)进行了一些实验.我至今仍无法真正找到NDK 不能做什么的清晰简洁定义(除了缺少异常处理和rtti).

I've been doing a fair amount of research, and have even experimented some with the NDK for Android (not so much the SDK). What I haven't been able to really find though is a clear and concise definition for what the NDK cannot do (besides lack of exception handling and rtti).

我一直在为Android的游戏和游戏引擎绘制一些代码(完全在NDK中编写),但似乎并没有像许多人希望的那样得到支持.不仅如此,我还想给我的游戏增添性感.无需在OpenGL中从头开始编写所有内容.

I've been mapping out some code for a game and a game engine for Android (Written entirely in the NDK) but it seems to not be as supported as many would like it to be. Not only that, but I'd like to be able to give my game a sexy U.I. without having to write everything from scratch in OpenGL.

虽然我确定Java会更容易,但我想知道NDK的前端/UI.组件在触摸屏IO,声音和图形界面方面甚至可以与Java相提并论.最坏的情况下我可以写U.I. Java中,然后从中调用本机方法,但我希望能够做更多的事情.

While I'm sure it's easier in Java, I'd like to know if the NDK's front end/U.I. components are getting to a point to where they'd even be comparable with Java in terms of Touchscreen IO , Sound, and Graphical Interfaces. Worst case scenario I can write the U.I. in Java and just call native methods from that, but I'd like to be able to do more if possible.

谢谢.

修改

如果C ++甚至可以与Java的U.I相提并论功能集,知道这两者可以提供更多的控制和自定义功能会很酷.例如,尽管Java实现可能更易于使用,但它是否为程序员提供了很多选择来微调类似于特定事物的外观"?

If C++ is even somewhat on par with Java's U.I. feature set, it would be cool to know which of the two gives more control and customization. For example, while the Java implementation may be easier to use, does it give the programmer a lot of options to fine tune a "look" which resembles something specific?

推荐答案

官方NDK可以做例外,而rtti可以.阅读随Android NDK分发的"docs/CPLUSPLUS-SUPPORT.html"文件.

Official NDK can do exceptions and rtti just fine. Read the "docs/CPLUSPLUS-SUPPORT.html" file distributed with Android NDK.

在C ++中,您唯一不能做的就是实现Java接口,继承Java类并定义新的Java类.否则,您可以做Java可以做的一切.唯一的问题是,很多事情(例如访问Java对象成员或调用Java函数)将需要使用JNI,并且代码看起来真的很丑.因此,如果需要UI创建/继承Java类,则可以使用C ++编写所有代码.

In C++ only thing you can not do is implement Java interface, inherit Java class and define new Java class. Otherwise - you can do everthing Java can. Only problem with that will be that a lot of things (like accessing Java object members, or calling Java functions) will require usage of JNI and that code will look really ugly. So if you need for UI creating/inheritance of Java classes, then you can code everything in C++.

我建议仅将JNI用于性能关键的代码.混合代码-用于UI的Java和C/C ++中的数学计算非常简单. 或者,如果您使用OpenGL ES编写游戏代码,也可以.

I suggest to use JNI only for performance critical code. Mixing code - Java for UI, mathematical calculations in C/C++ is really easy. Or if you code game by using OpenGL ES - that's also fine.

这篇关于就U.I而言,本机活动与SDK活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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