Friday 30 August 2013

How-to-use i18n(Internationalization) folder in Appcelerator

//  How-to-use i18n(Internationalization) folder

// Rather than hard-coding strings into your project, you can use localized strings. Localized strings are replaced at runtime with values appropriate to the user's language. Titanium relies on resources files and string placeholders to accomplish this task.

Example :)

 // Titanium provides two functions for obtaining a localized string from your resource files. Both take the key of the string requested as their first parameter. The L() macro is a short form for Ti.Locale.getString():


Helpful LINK :  https://wiki.appcelerator.org/display/guides/Internationalization

LIKE

var str1 = L('welcome_message');
var str2 = Ti.Locale.getString('welcome_message');
// str1 === str2

Sample code is available on GIT :) 
https://github.com/dharmik/How-to-use-i18n-folder--

Thursday 15 August 2013

How to use paint module and save that image in local . .

// In this blog we learn that how to use paint module in appcelerator

// This module is very easy to use.

// This paint module is available on appcelerator market place.

//Sample code is available here. :)

You can get module using this link

https://dl.dropboxusercontent.com/u/72783403/paint.zip


var Paint = require('ti.paint');

var win = Ti.UI.createWindow({
    backgroundColor : '#fff'
});
var paintView = Paint.createPaintView({
    top : 0,
    right : 0,
    bottom : 80,
    left : 0,
    strokeColor : 'black',
    strokeAlpha : 255,
    strokeWidth : 5,
    eraseMode : false
});
win.add(paintView);

var clear = Ti.UI.createButton({
    bottom : 40,
    right : 50,
    width : 75,
    height : 30,
    title : 'Clear'
});
clear.addEventListener('click', function() {
    paintView.clear();
});
win.add(clear);
var save = Ti.UI.createButton({
    bottom : 40,
    left : 50,
    width : 75,
    height : 30,
    title : 'Save'
});
save.addEventListener('click', function() {
    var filename = "sample.png";
    var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);

    if (file.exists()) {
        file.deleteFile();
    }

    file.write(paintView.toImage());
    var path = file.nativePath;
    Ti.API.info('path of image' + path);
    alert('Image Save');
});
win.add(save);

win.open();




Sunday 11 August 2013

Different project structure

// Today we simply discuss some project structure.

// How to display menu in appcelerator in different style.


// Sample code is available on GIT :)

https://github.com/dharmik/MenuStructure


Pic :)

 
 



Drag Pin on MAP in Android device In Appcelerator

// Today we learn something different in appcelerator .

// In appcelerator we all kown that we drag pin on Map in iOS we can easily do that .

// In iOS there are some property is available like Dragabble .

// With the use of this property we can easily drag that pin on map in iOS

// But HOW to DRAG that PIN on MAP in ANDROID Device in Appcelerator ?

// Draggable property is only available in iOS not for ANDROID.  :( :( :(

Here one video is available on Youtube that really good and with the help of this URL i solve my problem and that i share wuth you.

http://www.youtube.com/watch?v=M4fUlqKWg7g
And that sample code is also available on GIT.. :)

https://github.com/dharmik/Drag-Pin-In-Android

Friday 2 August 2013

Text Field In ALERT BOX in Android in APPCELERATOR

Below is Simple code for TextField in ALERT BOX. 



app.js

//Helpful code :)

var win = Titanium.UI.createWindow({
    backgroundColor:'#fff'
});

var textfield = Ti.UI.createTextField({
    value : 'Hello :)'
});

var dialog = Ti.UI.createAlertDialog({
    title: 'Enter text',
    androidView: textfield,
    buttonNames: ['OK', 'cancel']
});
dialog.addEventListener('click', function(e){
    Ti.API.info(textfield.value);
});
dialog.show();

win.open();

Snap :)