Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Titanium - Being duplicate view

$
0
0

I'm trying to build a tableview with while loop.

Per row, I add 2 Label ("Urltitle" and "Brief") and 1 ScrollableView (view1-view2-view3). In view1, I add 1 label ("Long" - Description).

"Urltitle", "Brief" and "Long" is also retrieved from Database.

When tableview loading is done (end of while loop), the duplicate appear. "Urltitle" and "Brief" is OK but the "Long" label is duplicate http://i.stack.imgur.com/6if9o.png

"Long" label of the "row 5" and "row 0" are the same but "Urltitle" and "Brief" are not.

Howerver, If I bring the "Long" label out of ScrollableView, It's good. The duplicate isn't happen. http://i.stack.imgur.com/o7crA.png

My code:

var data = [];
    var i = 0;
    var row = [];
    var viewRoot = [];
    var view1 = [];
    var view2 = [];
    var view3 = [];
    var scrollView = [];
    var urlTitle = [];
    var brief = [];
    var longDes = [];
    while (rows.isValidRow())
        {           
            row[i] = Ti.UI.createTableViewRow({
                backgroundColor: "transparent",
                className: "header",
                layout: "vertical",
                height: "auto"
            });
 
            viewRoot[i] = Ti.UI.createView({
                height: "auto",
                width: "95%",
                backgroundColor: "white",
                layout: "vertical",
            });
 
 
            view1[i] = Ti.UI.createView({
                height: "200",
                borderColor: "black",
                borderRadius: 10,
                borderWidth: 3,
                layout: "vertical",
            });         
            view2[i] = Ti.UI.createView({
                borderColor: "black",
                borderRadius: 10,
                borderWidth: 3,
                height: "auto",
            });
            view3[i]= Ti.UI.createView({
                borderColor: "black",
                borderRadius: 10,
                borderWidth: 3,
                height: "auto",
            });             
            scrollView[i] = Ti.UI.createScrollableView({
                views: [view1[i],view2[i],view3[i]],
                backgroundColor: "white",
                height: "200",
                showPagingControl: true,
            });
 
 
            urlTitle[i] = Titanium.UI.createLabel({
                text: rows.fieldByName("UrlTitle"),
                backgroundColor: "white",
                ellipsize: true,
                wordWrap: false,
                color: "blue",
                top: "5dp",
                left: "5dp",
                textAlign: "left",
                font: {
                    fontSize: 34,
                },
                height: "auto",
            }); 
            brief[i] = Titanium.UI.createLabel({
                text: rows.fieldByName("Brief"),
                backgroundColor: "white",
                ellipsize: true,
                wordWrap: false,
                color: "#006621",
                left: "5dp",
                textAlign: "left",
                font: {
                    fontSize: 28
                },
                height: "auto"
            });
            longDes[i] = Titanium.UI.createLabel({
                text: rows.fieldByName("Long"),
                backgroundColor: "white",
                color: "#000",
                left: "5dp",
                textAlign: "left",
                font: {
                    fontSize: 28
                },
                width: "auto",
                height: "auto"
            }); 
            view1[i].add(longDes[i]);
 
            viewRoot[i].add(urlTitle[i]);
            viewRoot[i].add(brief[i]);
            viewRoot[i].add(scrollView[i]);
            row[i].add(viewRoot[i]);
            data.push(row[i]);
            i++;
            rows.next();
        }

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>