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
2 Answers
-
Hi guys,go through this link.http://cl.ly/420v2U0K1Y3z47371821
-
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; } }
});