Titanium Community Questions & Answer Archive

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

ExpandableListView Available?

Is there any way to use ExpandableListView (http://developer.android.com/reference/android/widget/ExpandableListView.html) in an Adroid app created using Appcelerator/Titanium?

If so, where does one need to look for information on this? (Can't find anything remotely similar in API reference.)

If not, what would you advise to use for a series of headings that when clicked displays their (rows of) children?

Thanks

— asked September 2nd 2010 by Katy Ereira
  • android
  • api
  • expandable
  • list
  • mobile
0 Comments

2 Answers

  • Hi guys,go through this link.http://cl.ly/420v2U0K1Y3z47371821

    — answered September 7th 2012 by mukesh kumar
    permalink
    2 Comments
    • a zip file to download? do not trust!

      — commented September 14th 2012 by lord bharal
    • This is actually a working example, I guess they are using the same approach as described here: https://gist.github.com/946647

      — commented October 2nd 2012 by Olga Ryzhikova
  • I think the below code is most Promising is works for me.Even if u have better code please share with me.My EmailId is as 'sureshsharma842@gmail.com' .Because I m not able to navigate to another by clicking on the SubListItem of the Row of TableListView

    var tableView = Ti.UI.createTableView({
    left:15,
    top:15,
    borderRadius:5,
    borderColor:'#DAD7D7',
    borderWidth:1,
    backgroundColor:'white',
    width:290,
    height:'auto',
    scrollable:true,
    color:'black',
    font: {
    fontSize:15,
    fontFamily:'Helvetica Neue'
    },
    });

    /
    var dataArray = [];
    dataArray.push({title:"All Servise Request" },
    {title:"Notification"},
    {title:"User Management"},
    {title:"Services" },
    {title:"My Account"},
    {title:"Support" });
    /

    //RowGroup is declared here
    var rowData = [];

    var downImage='image/down.png';

    //First Row
    var row1 = Titanium.UI.createTableViewRow(
    {
    height: 'auto',
    className: 'board_row',
    isparent: true,
    opened: false,color:'black',
    sub:0
    });

    var serviceLabel1 = Titanium.UI.createLabel(
    {
        text:"All Servise Request" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    

    var trend1 = Titanium.UI.createImageView({
    image:downImage,
    width:'auto',
    height:'auto',
    right:10,
    top:5
    });

    row1.add(serviceLabel1);
    //row1.add(trend1);
    rowData.push(row1);
    

    //Second Row

    var row2 = Titanium.UI.createTableViewRow(
    {
        height: 'auto',
        className: 'board_row',
        isparent: true,
        opened: false,color:'black',     
        sub: 0
    });
    
    
    var serviceLabel2 = Titanium.UI.createLabel(
    {
        text:"Notification" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    
    
    var trend2=  Titanium.UI.createImageView({
    

    image:downImage,
    width:'auto',
    height:'auto',
    right:10,
    top:5
    });

    row2.add(serviceLabel2);
    //row2.add(trend2);
    rowData.push(row2);
    

    //Third Row

    var row3 = Titanium.UI.createTableViewRow(
    {
        height: 'auto',
        className: 'board_row',
        isparent: true,
        opened: false,color:'black',     
       sub: [
            {
                title: "Approve Registration",
                color:'blue'
            },
            {
                title: "Invite Portal Users",
                color:'blue'
            },
            {
                title: "Add Users",
                color:'blue'
            },
            {
                title: "Modify Users",
                color:'blue'
            },
            {
                title: "Copy Permission",
                color:'blue'
            },
            {
                title: "Create Password",
                color:'blue'
            }
        ]
    
    });
    
    
    var serviceLabel3 = Titanium.UI.createLabel(
    {
        text:"User Management" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    

    var trend3 = Titanium.UI.createView({
    backgroundImage:downImage,
    width:'20',
    height:'20',
    right:10,
    top:10
    });

    row3.add(serviceLabel3);
    row3.add(trend3);
    rowData.push(row3);
    
    //Forth Row
    
    var row4 = Titanium.UI.createTableViewRow(
    {
        height: 'auto',
        className: 'board_row',
        isparent: true,
        opened: false,color:'black',     
        sub:  [
            {
                title: "Cross Connect",
                color:'blue'
            },
            {
                title: "Smart Hands",
                color:'blue'
            },
            {
                title: "Accessories",
                color:'blue'
            },
            {
                title: "Other",
                color:'blue'
            },
            {
                title: "Shipments",
                color:'blue'
            },
            {
                title: "Site Visits",
                color:'blue',
                path:'siteVisit.js'
            }
        ]
    });
    
    
    var serviceLabel4 = Titanium.UI.createLabel(
    {
        text:"Services" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    

    var trend4 = Titanium.UI.createView({
    backgroundImage:downImage,
    width:'20',
    height:'20',
    right:10,
    top:10
    });

    row4.add(serviceLabel4);
    row4.add(trend4);
    rowData.push(row4);
    

    //Fifth Row

    var row5 = Titanium.UI.createTableViewRow(
    {
    height: 'auto',
    className: 'board_row',
    isparent: true,
    opened: false,color:'black',
    sub:0
    });

    var serviceLabel5 = Titanium.UI.createLabel(
    {
        text:"My Account" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    

    var trend5 = Titanium.UI.createImageView({
    image:downImage,
    width:'auto',
    height:'auto',
    right:10,
    top:10
    });

    row5.add(serviceLabel5);
    //row5.add(trend5);
    rowData.push(row5);
    

    //Sixth Row

    var row6 = Titanium.UI.createTableViewRow(
    {
        height: 'auto',
        className: 'board_row',
        isparent: true,
        opened: false,color:'black',     
        sub:0
    
    });
    
    
    var serviceLabel6 = Titanium.UI.createLabel(
    {
        text:"Account" ,
        font: 
        {
            fontSize: 18,
            fontWeight: 'bold'
        },
        width: 'auto',
        height: 'auto',
        textAlign: 'left',
        color: 'black',
        left: 4
    });
    

    var trend6 = Titanium.UI.createImageView({
    image:downImage,
    width:'auto',
    height:'auto',
    right:10,
    top:5
    });

    row6.add(serviceLabel6);
    //row6.add(trend6);
    rowData.push(row6);
    

    //Add data to tableView Here
    tableView.setData(rowData);

    tableView.addEventListener('click', function(e)
    {
    //Is this a parent cell?
    if(e.row.isparent) {

        //Is it opened?
        if(e.row.opened) {
    
    
            var currentIndex = e.index;
    
    
    
    
            //getting back from Expandables
            for(var i=e.row.sub.length; i > 0; i = i - 1) {
                tableView.deleteRow(e.index + i);
            }
            e.row.opened = false;
    
                if(currentIndex==3)
            {
                trend3.image='image/down.png';
            }
            else if(currentIndex==4)
            {
                trend4.image='image/down.png';
            }
    
        }
    
        else {
            //Add teh children.
            var currentIndex = e.index;
    
            if(currentIndex==3)
            {
                trend3.image='image/up.png';
            }
            else if(currentIndex==4)
            {
                trend4.image='image/up.png';
            }
    
            //getting Expandables
            for(var i=0; i < e.row.sub.length; i++) {
                tableView.insertRowAfter(currentIndex, e.row.sub[i]);
                currentIndex++;
            }
            e.row.opened = true;
        }
    
    }
    

    });

    — answered July 1st 2011 by Suresh Sharma
    permalink
    2 Comments
    • Hi Suresh, right now I also finding for Android ExpandableListView in Ti. If you have any update on it. Please share to me. Thanks a lot.

      — commented August 15th 2011 by Pye Phyo Han
    • Hi Suresh the example you have provided is not working well for me.
      I am looking for the same expandable List View in iPhone .In Android we already have .The same look and feel.
      If you got any examples please share it to me

      Thanks a lot

      — commented March 23rd 2012 by meenakshi umasanker
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.