Using JavaScript to write Android and iOS naitve apps is really cool.

Source: Internet
Author: User

Focus on Nativescript for some time, said the first beta version of March, finally released.

//declare the extended nativescriptactivity functionalityvarExtendsobject ={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        varbutton =NewAndroid.widget.Button ( This); Button.settext ("Hello World");  This. Setcontentview (button); }}//Pass the extends object to create a new nativescriptactivity instancevarMainactivity =com.tns.NativeScriptActivity.extends (extendsobject);varApplicationinitobject ={getactivity:function(Intent) {//This method is called whenever a new instance of Nativescriptactivity are about to be created        returnmainactivity; }, 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 contextApp.init (Applicationinitobject);

Like the code above, using JavaScript to build an Android activity, is not cool!

Of course it's also possible to write iOS native apps, which is not the coolest and even cooler, it also provides a set of "public" APIs, and a set of UI control libraries that can be described in XML, so you can define the interface and generate corresponding local controls on different platforms.

<Pagexmlns= "Http://www.nativescript.org/tns.xsd"Loaded= "pageLoaded">  <Stacklayout>    <Labeltext= "Tap the button"CssClass= "title"/>    <Buttontext= "Tap"Tap= "{{tapaction}}" />    <Labeltext= "{{message}}"CssClass= "message"TextWrap= "true"/>    <Buttontext= "Test Button"/>  </Stacklayout></Page>

It also supports "data binding", which you believe?!

Example of the sample:

Using JavaScript to write Android and iOS naitve apps is really cool.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.