Possible to have two tableview rows stacked horizontally next to each other?

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

I wanted to make my tableview a bit more of a grid system, so that two tableviewrow's were side to side per row

----------------------<br > | row 1 | row 2 |<br > | row 3 | row 4 |<br > | row 5 | row 6 |<br > | row 7 | row 8 |<br > ----------------------<br >

Hope this makes sense?

— asked 2 years ago by C H
0 Comments

4 Answers

Accepted Answer

It's easy. No webview needed - in fact avoid the webview as much as possible.Take a look at the code below:

var scrollview = Ti.UI.createScrollView({
    contentHeight:'auto',
    layout:'horizontal',
    width:320,
    height:320,
    backgroundColor:'#0ff'
});
 
var lbls = [];
 
for (var i=0; i < 30; i++) {
    lbls[i] = Ti.UI.createLabel({
        width:160,
        height:50,
        text:i,
        borderWidth:1,
        borderColor:'#555'
    });
 
    scrollview.add(lbls[i]);
};
 
 
the_window.add(scrollview);
The secret is layout:'horizontal' to make the cell (in this case the label) to have the
width = width_of_the_scrollview/number_of_cells_in_row
Of course you will have to figure out next what the cell is which but is not that hard

— answered 2 years ago by Dan Tamas
answer permalink
1 Comment
  • If you don't really need all the functionnalities of a tableView, rows and columns of labels could be a solution actually.

    As regards webView, Appcelerator recommends avoiding them as much as possible because they eat up a lot of resources. However, in some cases, using webView to display information is much simpler from a programmatic point of view than using native Titanium widgets, and is worth the additional resources' consumption.

    — commented 2 years ago by Laurent Jolia-Ferrier

I don't know exactly what you have in mind, but:

  • This is certainly not trivial if you really want to use a tableView (I tried a few things without any success): at the best you may have to rewrite a good portion of code;
  • Maybe a webView with a table would be more appropriate?
— answered 2 years ago by Laurent Jolia-Ferrier
answer permalink
1 Comment
  • Thanks for the try, I appreciate it. I might make an intricate group of views inside a scrollview I guess..

    — commented 2 years ago by C H

What is the reason for the grid? If you just want to put more information on the screen, then a simple tableview with two views added horizontally on each row will do the trick. If there is a reason for each cell to be a unique tableviewrow, you can have 2 tableviews side by side, but they will scroll independently. I'm not sure how difficult it would be to synchronize them.

Your Answer

Think you can help? Login to answer this question!