Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Is there any plan of supporting radio button in Titanium?

Is there any plan of supporting radio button in Titanium? As Android does support radio buttons? Is there any way to create radio button in Titanium?

— asked October 11th 2010 by Samir Desai
  • titanium
  • titanium mobile
  • titanium.ui.view
0 Comments

7 Answers

  • Here is a simple button bar with radio button action:

    var buttonObjects = [
      {title:'Morning'},
      {title:'Daytime'},
      {title:'Evening'}  
    ];
    
    var timeBb = Titanium.UI.createButtonBar({
        labels:buttonObjects,
        top:20,
        left:20,
        style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
        height:25,
        width:200
    });
    
    timeBb.addEventListener("click", function(e){
      for(var i=0;i<buttonObjects.length;i++) {
         buttonObjects[i].enabled = (i != e.index);
      }
      timeBb.labels = buttonObjects;
      Ti.API.info("You picked: " + buttonObjects[e.index].title);
    });
    win.add(timeBb);
    
    — answered November 10th 2010 by Dave Miller
    permalink
    3 Comments
    • "createButtonBar" is got problem in android. Could tell me which can I use for Android instead of "createButtonBar".

      — commented July 10th 2011 by Pye Phyo Han
    • problem in android

      — commented February 29th 2012 by Bhushan More
    • you made my day brother!

      — commented June 17th 2013 by parth jani
  • The iOS does not have radio buttons as part of their default component set. The Apple interface guidelines suggest using a different control, either a combopicker or a button bar. I went with the button bar with a label for the question.

    — answered October 11th 2010 by Chris Griffith
    permalink
    1 Comment
    • Thanks Chris. I am new to titanium and iPhone. Can you please give me the code how to create combopicker or a button bar which works as radio button?

      Any external link will also help.

      Thanks Again!!

      — commented October 12th 2010 by Samir Desai
  • Thanks Chris. I am new to titanium and iPhone. Can you please give me the code how to create combopicker or a button bar which works as radio button?

    Any external link will also help.

    — answered October 13th 2010 by Samir Desai
    permalink
    0 Comments
  • I guess what you want is a TabbedBar. Took me a while to figure that one out :(

    — answered April 19th 2011 by Enrico Thierbach
    permalink
    0 Comments
  • Hi..Titanium API is not provide radio button control for Android. its really bad to using put radio button images and handle that values. please improve titanium API control for android app.

    — answered February 5th 2013 by bhoomi Patel
    permalink
    0 Comments
  • Hold on. B4A has radio buttons that you can provide a result to and when clicked it sets up the associated variable to be pushed to backend. So, it is not bad control for Android.

    — answered August 14th 2013 by Ron Arnold
    permalink
    0 Comments
  • after 4 day work i got the Solution how to create Radio Group with radio button in titainum.Here i have created 2 button and taken 2 image which looks like checked box and unckecked box Below is the Code where you can easily implement in your project.

    var window=titanium.UI.createWindow();

    /////////////////////////////////////Radio Button1////////////////////////////////////
    var radio1 = Ti.UI.createButton({
    title: '',
    top: 160,
    left:57,
    width: 25,
    height: 25,
    backgroundImage: '/images/checked.png',//////Radio Button Images///
    color: '#fff',
    font:{fontSize: 25, fontWeight: 'bold'},
    value: true //value is a custom property in this casehere.
    });
    radio1.on = function() {
    this.backgroundImage='/images/checked.png';
    this.value = true;
    };

    radio1.off = function() {
    

    // this.backgroundColor = '#aaa';
    this.backgroundImage='/images/unchecked.png';
    this.title='';
    this.value = false;
    };
    radio1.addEventListener('click',function(e){
    if(false==e.source.value){
    e.source.on();
    radio2.backgroundImage='/images/unchecked.png';
    }else{
    // e.source.off();
    }

    });
    //////////////////////////////////////////Radio Button2///////////////////////////////////////////////

    var radio2 = Ti.UI.createButton({
    title: ' ',
    top: 160,
    left:190,
    width: 25,

    height:25,
    backgroundImage:'/images/unchecked.png',
    color: '#fff',
    font:{fontSize: 25, fontWeight: 'bold'},
    value: false //value is a custom property in this casehere.
    

    });

    radio2.on1 = function() {
    // this.backgroundColor = '#007690';
    // this.title='\u2713';
    this.backgroundImage='/images/checked.png';
    this.value = true;
    };

    radio2.off1 = function() {
    ///this.backgroundColor = '#aaa';
    

    // this.title='';
    this.backgroundImage='/images/unchecked.png';
    this.value = false;
    };
    radio2.addEventListener('click',function(e){
    if(false== e.source.value){
    e.source.on1();
    radio1.backgroundImage='/images/unchecked.png';
    }else{
    // e.source.off1();
    }
    //radio1.backgroundImage='/images/'
    });

    window.add(radio1);
    window.add(radio2);
    window.open();

    — answered August 27th 2015 by Rohit Yadav
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.