Reputation: 3156
I am new to Titanium Studio. Need to set row height dynamically but, I unable to set dynamic height in each row. Below is my code:
textArray contains 10 text paragraphs. each paragraph have different height.
var myTable = Ti.UI.createTableView({height:360, width: 306, top: 58, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
var myArray = [];
for(int i = 0; i < 10; i++)
{
var row = Ti.UI.createTableViewRow({contentHeight: 'auto', width: 320,top:0});
var my = Ti.UI.createView({ top:10,width:300,height:'auto' });
var myText = Ti.UI.createlLabel({text:textArray[i],width:50,height:'auto',left:10,top:5,borderRadius:4});
my.add(myText);
row.add(my);
myArray.push(row);
}
How can i set row height dynamically.
Can any one help?
Upvotes: 1
Views: 3976
Reputation: 3156
I got the solution:
specify your table rowHeight as auto.
var myTable = Ti.UI.createTableView({height:400,rowHeight: 'auto', width: 312, top: 10,left:4, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
var myArray=[];
for(int i = 0; i < 10; i++)
{
//create row in table.
var row = Ti.UI.createTableViewRow({height: 'auto', width: 310,top:10, selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE});
//textArray contains 10 elements. i am using this in each loop..
var myText = Ti.UI.createlLabel({text:textArray[i],width:50,height:50,left:10,top:5,borderRadius:4});
//add like this what ever you want...
row.add(myText);
myArray.push(row);
}
//store in table
myTable.data = myArray;
//disply table.
win.add(myTable);
If height:'auto' property is not working then use Ti.UI.SIZE
I hope.. someone will use it.
Upvotes: 1
Reputation: 2997
As per understanding you need to show cell height as per text
Here are some good example
Hope this will solve you problem.
Upvotes: 1