关注NativeScript有一段时间了,说好了的三月发第一个Beta版,终于发布了。

// declare the extended NativeScriptActivity functionality
var extendsObject = {
onCreate: function(savedState){
// call the base NativeScriptActivity.onCreate method
// the "this" variable points to a NativeScriptActivity instance
this.super.onCreate(savedState); // create a button and set it as the main content
var button = new android.widget.Button(this);
button.setText("Hello World"); this.setContentView(button);
}
} // pass the extends object to create a new NativeScriptActivity instance
var mainActivity = com.tns.NativeScriptActivity.extends(extendsObject); var applicationInitObject = {
getActivity: function(intent) {
// this method is called whenever a new instance of NativeScriptActivity is about to be created
return mainActivity;
},
onCreate: function() {
// This is the first method called. Called from the android.app.Application.onCreate method.
}
} // The NativeScriptRuntime exposes the app object within the global context
app.init(applicationInitObject);

如上面代码,用javascript创那建一个Android的Activity,是不是很炫酷!

当然也可以写iOS native应用,这还不是最炫酷的,更炫酷的是,它还提供了一套“公共的”api,和一套可以用xml描述的ui控件库,可以这样定义界面,并在不同的平台下生成相应用本地控件。

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<Label text="Tap the button" cssClass="title"/>
<Button text="TAP" tap="{{ tapAction }}" />
<Label text="{{ message }}" cssClass="message" textWrap="true"/>
<Button text="test button"/>
</StackLayout>
</Page>

它还支持“数据绑定”,这你敢信?!

上样例:

用javascript写Android和iOS naitve应用,实在炫酷。的更多相关文章

  1. iOS动画开发之五——炫酷的粒子效果

    在上几篇博客中,我们对UIView层的动画以及iOS的核心动画做了介绍,基本已经可以满足iOS应用项目中所有的动画需求,如果你觉得那些都还不够炫酷,亦或是你灵光一现,想用UIKit框架写出一款炫酷的休 ...

  2. iOS开发之 Lottie -- 炫酷的动效

    动效在软件开发中非常常见,炫酷的动画能提升应用的B格,然而由设计师的设计转化成程序猿GG的代码是个非常"痛苦"的过程.对于复杂动画,可能要花费很多时间去研究和实现.Lottie 的 ...

  3. 【Android珍藏】推荐10个炫酷的开源库【转】

    感谢大佬:https://www.jianshu.com/p/d608f0228fd4 前言 技术群里面经常有人问到一些炫酷的UI效果实现方法,有时候我都是给一个相同或者相似效果的Github链接,有 ...

  4. Android自定义View(RollWeekView-炫酷的星期日期选择控件)

    转载请标明出处: http://blog.csdn.net/xmxkf/article/details/53420889 本文出自:[openXu的博客] 目录: 1分析 2定义控件布局 3定义Cus ...

  5. iOS动画进阶 - 实现炫酷的上拉刷新动效

    移动端訪问不佳,请訪问我的个人博客 近期撸了一个上拉刷新的小轮子.仅仅要遵循一个协议就能自己定义自己动效的上拉刷新和载入,我自己也写了几个动效进去,以下是一个比較好的动效的实现过程 先上效果图和git ...

  6. 毫无保留开源我写的:IOS Android Ipad 多点触摸通用js 库

    毫无保留开源我写的:IOS Android Ipad 多点触摸通用js 库 在线演示地址: http://m.yunxunmi.com/ 支持 IOS Android Ipad 等不同操作系统的手持或 ...

  7. Android &Swift iOS开发:语言与框架对比

    转载自:http://www.infoq.com/cn/articles/from-android-to-swift-ios?utm_campaign=rightbar_v2&utm_sour ...

  8. 总结使人进步,可视化界面GUI应用开发总结:Android、iOS、Web、Swing、Windows开发等

    可视化界面的软件,是21世纪最主流的应用类型了,黑屏控制台的不适合普通用户.   2004年左右的时候,作为普通网民,接触的自然是可视化,准确是Windows那一套.   那个时候,Microsoft ...

  9. HTML5能取代Android和iOS应用程序吗?

    大量新生移动设备的兴起,改变了互联网的未来.在技术的发展上,HTML5会取代App应用吗?或者说能够在多大程度上取代呢?在HTML5规范中,已经加入了相机.磁力罗盘.GPS信息的支持.很多新兴浏览器也 ...

随机推荐

  1. redis集群安装

    1.普通安装 安装环境 centos 6.8 1.安装必要包 yum install gcc yum -y install wget 2.下载解压 wget http://download.redis ...

  2. 使用echarts

    <html> <head> <script type="text/javascript" src='echarts.min.js'></s ...

  3. Spring 4 官方文档学习(十三)集成其他web框架

    重点是通用配置,非常建议看一下!有助于理解Spring的ApplicationContext与Servlet Container的关系! 1.介绍 Spring Web Flow SWF目标是成为we ...

  4. JS 关闭页面事件

    主页面调用:<script src="<%=ResolveUrl("../JS/QuitJS.js") %>" type="text ...

  5. Android学习 之 ColorStateList按钮文字变色

    首先添加一个ColorStateList资源XML文件,XML文件保存在res/color/button_text.xml: <?xml version="1.0" enco ...

  6. linux下配置nginx使用service nginx start 服务

    解压出来后执行 mkdir /var/tmp/nginx/client/ -pv 接下来我们简单的为它提供一个服务脚本吧! # vim  /etc/init.d/nginx 新建文件/etc/rc.d ...

  7. Java变量自增和自减运算符的用法

    1.后加加(num++): 先输出运算结果再加加: public static void main(String[] args){ int num=10; int  p1=num++; System. ...

  8. Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules

    在eclipse里面配置tomcat时候遇到的问题: Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web mo ...

  9. The implementation details of the built thermal setup

    Lucid infrared thermography of thermally-constrained processors

  10. Good-Bye

    嘛……以一种奇怪的姿势滚粗了…… 如果这个Blog能给未来的OIer们一些帮助的话,它也不枉存在了…… 我的OI之路也能以另一种形式延续下去吧…… 也许能搞ACM的话会再开?…… 不管怎么说,各位再见 ...