button wont work on android

You must Login before you can answer or comment on any questions.

hi every one...i created a a few buttons in location1.js but the button are not responding in a Samsung Galaxy skyrocket...but when i run it in the Iphone simulator i can see the button respond because of the shade when i click...but i also have a simliar code in location3.js but this time instead of using buttons i used labels...those label work fine...i want the buttons to work..can someone help?

location1.js not working

function location1(_args) {
 
var win = Ti.UI.createWindow({
        title: 'Location#1',
        barImage:'navbar.png',
        backgroundColor:'white',
        width:320,
        height:470,
    });
 
 
 var address = Ti.UI.createLabel({
    text:'4888 NW 183 St,Miami fl 33055 Unit#214',
    top : 190,
      width : 'auto',
      height : '45',
   });
 
 
 
var image = Ti.UI.createImageView ({
    image:'/images/location1.jpg',
    top:0,
    height:200,
    width:320,
    });
 
 var staff = Ti.UI.createLabel({
 
      text : 'Staff',
      top : 220,
      width : '50',
      height : '45',
 
      color:'red',
      font:{fontSize:20,fontWeight:'bold'},
 
    });
    var callBtn = Ti.UI.createButton({
        width:'35',
        top:255,
        title:'call',
 
        left:150,
        backgroundImage:'/images/Phone.png',
    });
 
 
    win.add(callBtn);
 
    callBtn.addEventListener('click', function(){
       Titanium.Platform.openURL('Tel:7864880753');
    });
 
 
var Danny  = Ti.UI.createLabel({
 
      text : 'Danny Sensation',
      top : 250,
      width : '100%',
      height : '45',
 
    });
var callBtn1 = Ti.UI.createButton({
        width:'35',
        top:283,
        title:'call',
        left:70,
        backgroundImage:'/images/Phone.png',
    });
 
 
 
 
    callBtn1.addEventListener('click', function(){
       Titanium.Platform.openURL('Tel:7868739207');
    });
win.add(callBtn1);
 
 
var David = Ti.UI.createLabel({
      text : 'David ',
      top : 270,
      width : '100%',
      height : '45'
    });
 
 win.add(David);
 
   var callBtn2 = Ti.UI.createButton({
    width:'35',
        top:300,
        title:'call',
        left:105,
        backgroundImage:'/images/Phone.png',
 
 
   });
   callBtn2.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7868739207');
    });
 
 
   win.add(callBtn2);
 
    var Pocho = Ti.UI.createLabel({
      text : 'Pocho ',
      top : 295,
            width : '100%',
      height : '45'
    });
  var callBtn3 = Ti.UI.createButton({
        width:'35',
        top:320,
        title:'call',
        left:138,
        backgroundImage:'/images/Phone.png',
 
  });
  callBtn3.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7868739207');
    });
 
 
     win.add(callBtn3);
 
      var Rico = Ti.UI.createLabel({
      text : 'Rico Tha barber',
      top : 315,
      width : '100%',
      height : '45'
    });
 
 
var callbtn4 = Ti.UI.createButton({
        width:'35',
        top:345,
        title:'call',
        left:100,
        backgroundImage:'/images/Phone.png',
 
 
 
});
 
 callbtn4.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7868739207');
    });
 
 
 win.add(callbtn4);
 
  var Abi = Ti.UI.createLabel({
      text : 'Abi Fade ',
      top : 335,
      width : '100%',
      height : '45'
    });
 
var callbtn5 = Ti.UI.createButton({
        width:'35',
        top:363,
        title:'call',
        left:68,
        backgroundImage:'/images/Phone.png',
 
});
 
callbtn5.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7868739207');
    });
 
 
win.add(callbtn5);
 
   var Omar = Ti.UI.createLabel({
      text : 'Omar ',
      top : 355,
      width : '100%',
      height : '45'
    });
 
var callbtn6 = Ti.UI.createButton({
    width:'35',
        top:385,
        title:'call',
        left:40,
        backgroundImage:'/images/Phone.png',
 
});
callbtn6.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7868739207');
    });
win.add(callbtn6);
  var Gary = Ti.UI.createLabel({
      text : 'Gary ',
      top : 375,
      width : '100%',
      height : '45'
    });
var callbtn7 = Ti.UI.createButton({
 
    width:'35',
    top:400,
    title:'call',
    left:130,
    backgroundImage:'/images/Phone.png',
});
 
callbtn7.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7866247787');
    });
 
win.add(callbtn7);
var mambo = Ti.UI.createLabel({
    text:'Mambo Style',
     top : 400,
      width : '100%',
      height : '45',
         color:'red',
      font:{fontSize:20,fontWeight:'bold'},
    });
 
 
 
 
     var backBtn = Ti.UI.createButton({ title:'back' });
 
backBtn.addEventListener('click', function(){
    win.close();
});
win.setLeftNavButton(backBtn);
        win.open({
            modal : true,
            animated : false
        });
 
 
 
  win.add(mambo);
   win.add(Gary); 
  win.add(Omar); 
  win.add(Abi);
   win.add(Rico); 
   win.add(Pocho);
   win.add(staff);
   win.add(Danny);
  win.add(David);
 win.add(image);
 
 win.add(address);
//view.add(backBtn);
 
 return win;
 };
module.exports = location1;

location3.js ... similar code but working fully

function location3(_args) {
 
var win = Ti.UI.createWindow({
        title: 'Location#3',
        barImage:'navbar.png',
        backgroundColor:'white',
        width:320,
        height:470,
    });
 
 
var image = Ti.UI.createImageView ({
    image:'/images/location3.jpg',
    top:0,
    height:200
    ,
    width:350,
    });
 
    var backBtn = Ti.UI.createButton({ 
     title : 'Back' ,
     top:0,
     left:0,
});
 
var address = Ti.UI.createLabel({
      text : '1750 NE 163rd Street,North Miami Fl 33162 ',
      top : 200,
      width : 'auto',
      height : '45',
 
});
 
 var staff = Ti.UI.createLabel({
       text : 'Staff',
      top : 230,
      width : '50',
      height : '45',
 
      color:'red',
      font:{fontSize:20,fontWeight:'bold'},
 
 });
 
 var Dereck = Ti.UI.createLabel({
      text : 'Dereck : Tel:786 272 5345',
      top : 265,
      width : '100%',
      height : '45'
    });
 
   Dereck.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7862725345');
    });
 
 
     var Cesar = Ti.UI.createLabel({
      text : 'Cesar : Tel:786 923 6777',
      top : 290,
      width : '100%',
      height : '45'
    });
 
   Cesar.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7869236777');
    });
 
       var Jordhy = Ti.UI.createLabel({
      text : 'Jordhy : Tel:786 539 9565',
      top : 312,
      width : '100%',
      height : '45'
    });
 
   Jordhy.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7865399565');
    });
 
      var Cedric = Ti.UI.createLabel({
      text : 'Cedric : Tel:989 444 2979',
      top : 335,
      width : '100%',
      height : '45'
    });
 
   Cedric.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:9894442979');
    });
 
 
     var Bryant = Ti.UI.createLabel({
      text : 'Bryant : Tel:786 624 7787',
      top : 360,
      width : '100%',
      height : '45'
    });
 
   Bryant.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7866247787');
    });
 
      var Mambo = Ti.UI.createLabel({
      text : 'Mambo : Tel:786 624 7787',
      top : 390,
      width : '100%',
      height : '45',
         color:'red',
      font:{fontSize:20,fontWeight:'bold'},
    });
 
   Mambo.addEventListener('click', function(){
       Titanium.Platform.openURL('tel:7866247787');
    });
 
win.setLeftNavButton(backBtn);
 
backBtn.addEventListener('click', function(){
    win.close();
});
 
var backBtn = Ti.UI.createButton({ title:'back' });
 
backBtn.addEventListener('click', function(){
    win.close();
});
win.setLeftNavButton(backBtn);
        win.open({
            modal : true,
            animated : false
        });
 
 
win.add(Mambo);
win.add(Bryant);
win.add(Cedric);
win.add(Jordhy);
win.add(Cesar);
win.add(Dereck);
win.add(staff);
win.add(address);
 
 
win.add(image);
 
return win;
 };
 
module.exports = location3;

1 Answer

Accepted Answer

Buttons work just fine on android. This is an awful lot of code you've presented us. I don't see anything obviously wrong with it.

I would suggest you create a separate app.js that demonstrates this problem in 50 lines or less. In fact, build one window with both a button and a label. If you can build an example like this where the button doesn't work and the label does, I'll run your code myself and help you figure out what's wrong.

Full disclosure: I expect that if you take my advice and try to build such a simple case, you'll figure out what you're doing wrong. Building minimal cases like this is the best way to master this platform when things don't work as expected. I understand why developers are reluctant to do it -- it's very time-consuming. But it works.

— answered 9 months ago by Jason Priebe
answer permalink
4 Comments
  • Ok so i will build a window using commonjs .and then require it to see if i can figure it out

    — commented 9 months ago by Ronny Rodriguez

  • I would go even simpler than that.

    app.js:

    var win = Ti.UI.createWindow({
        title:'test',
        backgroundColor:'#fff',
        layout: 'vertical'
    });
     
    // add your parameters and event listener
    var btn = Ti.UI.createButton({...});
    win.add (btn);
     
    // add your parameters and event listener
    var lbl = Ti.UI.createLabel({...});
    win.add (lbl);
     
    win.open ();
    Just one file -- 50 lines or less. I can take that file, paste it into Ti.Studio and have it running in 30 seconds.

    — commented 9 months ago by Jason Priebe

  • your right it worked fine...i create a new app to test and it worked...ima have to check my code to see if it works

    — commented 9 months ago by Ronny Rodriguez

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!