1. Home
  2. /
  3. Titanium-appcelerator
  4. /
  5. Titanium Auto Increment Counter

Titanium Auto Increment Counter - Titanium-appcelerator Typing CST Test

Loading…

Titanium Auto Increment Counter — Titanium-appcelerator Code

Counter that automatically increments every second.

var win = Ti.UI.createWindow({backgroundColor:'white'});
var count = 0;

var label = Ti.UI.createLabel({text:'Counter: 0', top:50, font:{fontSize:24}});
var pauseButton = Ti.UI.createButton({title:'Pause/Resume', top:100});
var resetButton = Ti.UI.createButton({title:'Reset', top:150});

var isRunning = true;
var interval = setInterval(function(){
	if(isRunning){
		count++;
		label.text = 'Counter: ' + count;
	}
},1000);

pauseButton.addEventListener('click', function(){
	isRunning = !isRunning;
});

resetButton.addEventListener('click', function(){
	count=0;
	label.text='Counter: ' + count;
});

win.add(label);
win.add(pauseButton);
win.add(resetButton);
win.open();

Titanium-appcelerator Language Guide

Titanium Appcelerator is an open-source mobile development framework that allows developers to build native iOS and Android apps using JavaScript, providing a single codebase for multiple platforms.

Primary Use Cases

  • ▸Cross-platform native mobile apps (iOS and Android)
  • ▸Enterprise mobile applications
  • ▸Mobile apps requiring deep native API integration
  • ▸Rapid prototyping of mobile solutions
  • ▸Single codebase development for multiple platforms

Notable Features

  • ▸Cross-platform native mobile development
  • ▸Access to native device APIs via JavaScript
  • ▸Alloy MVC framework for structured app development
  • ▸Support for push notifications, geolocation, camera, and sensors
  • ▸CLI tools for scaffolding, building, and packaging apps

Origin & Creator

Created by Appcelerator, Inc. in 2008 to simplify cross-platform native mobile development using JavaScript.

Industrial Note

Titanium is widely used in enterprise mobile applications where native performance and device API access are required, particularly in banking, healthcare, and logistics apps.

Quick Explain

  • ▸Titanium converts JavaScript code into native UI components at runtime for iOS and Android.
  • ▸It supports access to native device APIs without writing Objective-C, Swift, or Java/Kotlin.
  • ▸Titanium emphasizes rapid development, cross-platform consistency, and native performance.

Core Features

  • ▸Native UI components for iOS and Android
  • ▸Alloy MVC framework for structured app architecture
  • ▸JavaScript bridge for accessing native APIs
  • ▸Support for Titanium SDK modules
  • ▸Cross-platform debugging and testing tools

Learning Path

  • ▸Learn JavaScript fundamentals
  • ▸Understand Titanium CLI and SDK
  • ▸Learn Alloy MVC architecture
  • ▸Practice building native mobile apps
  • ▸Integrate device APIs and third-party modules

Practical Examples

  • ▸Building a login form with TextField and Button
  • ▸Displaying lists with TableView and TableViewRow
  • ▸Using Geolocation API to track user location
  • ▸Integrating push notifications
  • ▸Accessing device camera to capture images

Comparisons

  • ▸True native apps vs Ionic’s hybrid apps
  • ▸JavaScript-based cross-platform like React Native
  • ▸Structured Alloy MVC vs Ionic/Quasar component-based
  • ▸Focused on mobile vs Ionic/Ionic PWA/web support
  • ▸Enterprise-ready modules vs general-purpose UI frameworks

Strengths

  • ▸Single JavaScript codebase for iOS and Android
  • ▸True native UI performance
  • ▸Access to almost all native device APIs
  • ▸Structured app development via Alloy
  • ▸Large ecosystem of community modules

Limitations

  • ▸Limited support for web or desktop apps
  • ▸Learning curve for Alloy MVC and Titanium APIs
  • ▸Some platform-specific bugs or inconsistencies
  • ▸Smaller community compared to React Native or Ionic
  • ▸Updates tied to Titanium SDK releases

When NOT to Use

  • ▸Web-only applications
  • ▸Progressive Web Apps (PWA)
  • ▸Desktop applications
  • ▸Projects requiring large community support or modern frontend frameworks
  • ▸Rapid prototyping for cross-framework apps

Cheat Sheet

  • ▸`Window`, `View`, `Label`, `Button` - UI components
  • ▸`app/controllers/` - controllers JS
  • ▸`app/views/` - XML views
  • ▸`app/styles/` - TSS styling files
  • ▸`tiapp.xml` - project configuration

FAQ

  • ▸Is Titanium free?
  • ▸Yes - core SDK is open-source under Apache 2.0.
  • ▸Does Titanium support native apps?
  • ▸Yes - for iOS and Android.
  • ▸Is Titanium cross-platform?
  • ▸Yes - a single JS codebase can target iOS and Android.
  • ▸Can I access device APIs?
  • ▸Yes - via Titanium APIs or custom modules.
  • ▸Which platforms are supported?
  • ▸iOS and Android (native apps).

30-Day Skill Plan

  • ▸Week 1: Basic UI components (Label, Button, TextField)
  • ▸Week 2: Navigation and TableView
  • ▸Week 3: Alloy MVC basics (Models, Views, Controllers)
  • ▸Week 4: Access native device APIs
  • ▸Week 5: Build full enterprise-ready cross-platform app

Final Summary

  • ▸Titanium Appcelerator enables native iOS and Android apps using JavaScript.
  • ▸Provides Alloy MVC for structured development.
  • ▸Access to full native device APIs without native coding.
  • ▸Ideal for enterprise mobile apps and rapid cross-platform development.
  • ▸Focuses exclusively on mobile, unlike hybrid frameworks.

Project Structure

  • ▸app/controllers/ - controller JS files
  • ▸app/views/ - XML view files
  • ▸app/styles/ - TSS styling files
  • ▸app/models/ - data models
  • ▸tiapp.xml - main project configuration

Monetization

  • ▸Enterprise mobile solutions
  • ▸Develop reusable Titanium modules
  • ▸Provide consulting for cross-platform apps
  • ▸Rapid prototyping for clients
  • ▸Mobile app maintenance services

Productivity Tips

  • ▸Use Alloy MVC for structured development
  • ▸Leverage Titanium modules for native APIs
  • ▸Test frequently on real devices
  • ▸Organize code with controllers and views
  • ▸Use CLI tools for rapid builds and deployment

Basic Concepts

  • ▸Views: Window, View, ScrollView, TableView
  • ▸UI components: Label, Button, TextField, ImageView
  • ▸Controllers manage app logic
  • ▸Models manage data via Alloy
  • ▸Events handle user interactions and system notifications

Official Docs

  • ▸https://titaniumsdk.com/
  • ▸https://github.com/appcelerator/titanium_mobile
  • ▸https://docs.appcelerator.com/platform/latest/#!/guide/Titanium

More Titanium-appcelerator Typing Exercises

Titanium Appcelerator Simple Todo AppTitanium Counter AppTitanium Todo App With DeleteTitanium Dark Mode CounterTitanium Multi Counter AppTitanium Todo With PriorityTitanium Countdown TimerTitanium Counter With Alert

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher