Add footerView to TableViewSection in android.

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

How to do it? It doesn't work for me. My code sample:

var addPhoneView = new UIElement({
            constructor: ui.createView,
            params: {
                width: 100,
                height: "auto",
                backgroundColor: "green"
            },
            styles: [
            ]
        });
 
        var addPhoneButon = new UIElement ({
            constructor: ui.createButton,
            params: {
                title: "Add Phone",
                //top: 10,
                height: 100
            },
            styles: [
                style.ACTION_BUTTON
            ]
        });
        addPhoneView.add(addPhoneButon);
        addPhoneButon.addEventListener("click", addPhone);
 
        var section = new UIElement({
            constructor: ui.createTableViewSection,
            params: {
                headerTitle: "Phone numbers",
                footerView: addPhoneView // FIXME Doesn't work :(
            },
            styles: [
            ]
        });
But if i add addPhoneView to headerView - it work's! What's wrong with footerView?

1 Answer

Hi Alexander

As you have not provided the UIElement I cannot see where you have gone wrong, however I can show you how to 'go' right.

Adapt this to suit your needs. I have one guess to your specific issues - are you passing footerView down the chain into theUIElement`?

var viewFooter = Ti.UI.createView({
  height: Ti.UI.SIZE,
  width: Ti.UI.FILL
});
var lbl = Ti.UI.createLabel({
  height: Ti.UI.SIZE,
  text: 'Hello from the Footer',
  width: Ti.UI.FILL
});
viewFooter.add(lbl);
 
var tbl = Ti.UI.createTableView({
  data: data,
  footerView: viewFooter,
  height: Ti.UI.SIZE,
  width: Ti.UI.FILL
});
win.add(tbl);

— answered 10 months ago by Malcolm Hollingsworth
answer permalink
10 Comments
  • Thank you, Malcolm,

    YOur code work's, but i asked about TableViewSection's footerView. It is works for tableview footer and header, and it work's for tableviewsection.headeView. But it is wrong when i try to set TableViewSection.footerView.

    — commented 10 months ago by Alexander Perechnev

  • Sorry about that - I must have been looking through my eye that does not work :)

    One difference between iOS usage and Android usage is that the footerView must be set during the creation of the tableviewsection, so not using a property or setFooterView() once you have created it - which might be happening if you are using intelligent property usage - which I suspect you are (for good reason).

    Can you check that, and report back. If that is correct could you provide the UIElement code snippet and I will work out some more code for you.

    Cheers

    — commented 10 months ago by Malcolm Hollingsworth

  • UIElement is a very simple:

    function UIElement(options) {
        var uiConstructor = options.constructor;
        var elementParams = options.params || {};
        var styles = options.styles || [];
        var androidParams = options.android || {};
        var iOSParams = options.iOS || {};
     
        utils.assertType(uiConstructor, "function");
     
        var css = require("/core/style");
     
        for (var i = 0; i < styles.length; i++) {
            var style = styles[i];
     
            elementParams = css.applyStyle(elementParams, style);
        }
        if (platform.isIOS()) {
            elementParams = applyPlatformSpecific(elementParams, iOSParams);
        } else if (platform.isAndroid()) {
            elementParams = applyPlatformSpecific(elementParams, androidParams);
        }
     
        return uiConstructor(elementParams);
     
        function applyPlatformSpecific(elementParams, style) {
            for (var prop in style) {
                if (style.hasOwnProperty(prop)) {
                    elementParams[prop] = style[prop];
                }
            }
            return elementParams;
        }
    }

    — commented 10 months ago by Alexander Perechnev

  • Show 7 more comments

Your Answer

Think you can help? Login to answer this question!