Monday, 22 June 2015

how to create Progress Indicator in titanium ?

It is very simple to create Progress Indicator. the blow code used create ProgressIndicator, show and hide ProgressIndicator

ProgressIndicator does not allow to another action before close the ProgressIndicator.

var ind=Ti.UI.Android.createProgressIndicator({
width:150,
height:50,
min:0,
max:1,
value:0,
style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN,
top:10,
message:'Please Wait...',
font:{fontSize:12, fontWeight:'bold'},
color:'#888'
});
emailwindow.add(ind);


first create above code and then add to window

ind.show();// show the ProgressIndicator

ind.hide();// hide the ProgressIndicator

Sunday, 21 June 2015

how to show time picker dialog in titanium?

show time picker dialog is very simple in titanium. Titanium use javascript code to get time we can change based on our requirement

imagetime.addEventListener('click',function(e)
{
pickerRecallTime = Ti.UI.createPicker({
   //top: 70,
   //left: 10,
   useSpinner: true,
   format24: false,
   selectionIndicator: true,
   type: Ti.UI.PICKER_TYPE_TIME
});

       pickerRecallTime.showTimePickerDialog({
           callback: function(e) {
               if (e.cancel) {
                   Ti.API.info('user canceled dialog');
       } else {
           //Ti.API.info('user selected Time: ' + e.value);
           //starttimefield.setValue(e.value);          
            var data = e.value;
    var hours = data.getHours();
    var minutes = data.getMinutes();    

starttimeflag=hours+':'+minutes;

 var ampm = hours >= 12 ? 'PM' : 'AM';
 hours = hours % 12;
 hours = hours ? hours : 12; // the hour '0' should be '12'
 minutes = minutes < 10 ? '0'+minutes : minutes;
 var strTime = hours + ':' + minutes + ' ' + ampm;
 //return strTime;  
    timefield.setValue(strTime);// set time in time field
   
       }
   }
});
});

how to show time picker dialog in titanium?

show time picker dialog is very simple in titanium. Titanium use javascript code to get time we can change based on our requirement

imagetime.addEventListener('click',function(e)
{
pickerRecallTime = Ti.UI.createPicker({
   //top: 70,
   //left: 10,
   useSpinner: true,
   format24: false,
   selectionIndicator: true,
   type: Ti.UI.PICKER_TYPE_TIME
});

       pickerRecallTime.showTimePickerDialog({
           callback: function(e) {
               if (e.cancel) {
                   Ti.API.info('user canceled dialog');
       } else {
           //Ti.API.info('user selected Time: ' + e.value);
           //starttimefield.setValue(e.value);          
            var data = e.value;
    var hours = data.getHours();
    var minutes = data.getMinutes();    

starttimeflag=hours+':'+minutes;

 var ampm = hours >= 12 ? 'PM' : 'AM';
 hours = hours % 12;
 hours = hours ? hours : 12; // the hour '0' should be '12'
 minutes = minutes < 10 ? '0'+minutes : minutes;
 var strTime = hours + ':' + minutes + ' ' + ampm;
 //return strTime;  
    timefield.setValue(strTime);// set time in time field
   
       }
   }
});
});

how to show datepicker dialog in titanium?

show date picker dialog is very simple in titanium. Titanium use java script code to get date

imagedate.addEventListener('click',function(e)
{
var picker = Ti.UI.createPicker({
 type:Ti.UI.PICKER_TYPE_DATE,
 minDate:new Date(2015,6,8),
 maxDate:new Date(2040,12,31),
 value:new Date(2015,6,8)
});

picker.showDatePickerDialog({
 value: new Date(2010,8,1),
 callback: function(e) {
   if (e.cancel) {
     Ti.API.info('User canceled dialog');
   } else {
    var data = e.value;
    var day = data.getDate();
   day = day.toString();

   if (day.length < 2) {
       day = '0' + day;
   }

   var month = data.getMonth();
   //month = month + 1;
   month = month.toString();

   if (month.length < 2) {
       month = '0' + month;
   }

   var year = data.getFullYear();
 
      startdate.setValue( day + "-" + month + "-" + year);
      datefield=year+"-"+month+"-"+day;// Set Date in
   }
 }
});
});

How to use toast in titanium ?

It is very simple to use in titanium
The example is given below

var toast = Titanium.UI.createNotification({
    duration: 2000,
    message: "Deleted Successfully"
});
toast.show();

How to create popup window?.

It's is very simple to create popup window in titanium


The app.js file is given below

var window = Ti.UI.createWindow({
height:"100%",
width:"100%",
top:"0%",
left:'0%'
});
var view = Titanium.UI.createView({
borderRadius:10,
backgroundColor: '#fff',
top: '0%',
left: '1%',
width: '100%',
height: '100%'
});
window.add(view);
var button = Titanium.UI.createButton({
    title: 'Add Reminder',

backgroundColor: '#2111B4',
    top: '20%',
    left: '25%',
    width: '43%',
    height: '8%'
});
view.add(button);
button.addEventListener('click',function(e)
{
    //Titanium.API.info("You clicked the button");
    //alert("Hi this Alert Message");
    var popupwindow=Ti.UI.createWindow({
    title:"Popup Window",
    modal:true,
    url:"module/popupwindow.js"
   
    });
    popupwindow.open();
});


the modal  should be give as modal:true


var window = Ti.UI.currentWindow;
var closeimag=Ti.UI.createImageView({
image:'/images/close.png',
top: '7%',
left: '85%',
width: '12%',
height: '13%',
});
view.add(closeimag);

var lineimage=Ti.UI.createImageView({
image:'/images/line.png',
width:'100%',
top:'20%',
left:'0%'
});
view.add(lineimage);

var label1 = Ti.UI.createLabel({
    color: '#4C4C4D',
    font: { fontSize:14 },
    text: 'Set Reminder',
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
    top: '10%',
    left: '26%',
    width: '44%',
    height: '8%',
});
view.add(label1);
var remidertitle = Ti.UI.createTextField({
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color: '#4C4C4D',
top: '25%',
left: '5%',
width: '90%',
height: '20%',
hintText: 'Reminder Name'
});
view.add(remidertitle);

closeimag.addEventListener('click',function(e)
{
     Titanium.API.info("You clicked the Cancel button");
     window.close();
});

button1.addEventListener('click',function(e)
{
   alert('add');
});