Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14496] Android: setHeaderView for Titanium.UI.TableViewSection

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-12-01T23:58:02.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsandroid, docs, headerview, tableviewsection
ReporterManuel Lehner
AssigneeHieu Pham
Created2013-07-08T19:54:39.000+0000
Updated2015-03-12T17:34:57.000+0000

Description

Currently, it is only possible to set the *headerView* of a TableViewSection at creation-time in Android. It would be great to use the *setHeaderView* method for Android too. In the Docs there is no note that this method is not available in Android: [http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableViewSection-method-setHeaderView]. There is only a hint at the *headerView* property description (_"On Android, must be set at creation."_): [http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TableViewSection-property-headerView] Q&A: [http://developer.appcelerator.com/question/154498/alloy-how-to-set-controller-as-headerview-to-tableviewsection-in-android]

Comments

  1. Manuel Lehner 2014-04-17

    Here is a simple test case:
       Ti.UI.backgroundColor = 'white';
       var win = Ti.UI.createWindow();
       
       var fruitHeader = Ti.UI.createView({
           width: Ti.UI.FILL,
           height: 50,
           backgroundColor: 'blue'
       });
       
       // setting headerView at creation works
       var sectionFruit = Ti.UI.createTableViewSection({ headerView: fruitHeader });
       sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
       sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
       
       var vegHeader = Ti.UI.createView({
           width: Ti.UI.FILL,
           height: 50,
           backgroundColor: 'red'
       });
       
       // setting headerView after creation fails
       var sectionVeg = Ti.UI.createTableViewSection();
       
       sectionVeg.setHeaderView(vegHeader); // Uncaught TypeError: Object #<TableViewSection> has no method 'setHeaderView' 
       
       sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
       sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));
       
       var table = Ti.UI.createTableView({
         data: [sectionFruit, sectionVeg]
       });
       
       win.add(table);
       win.open();
       
  2. Manuel Lehner 2014-04-17

    PR: https://github.com/appcelerator/titanium_mobile/pull/5619
  3. Manuel Lehner 2014-10-10

    I can't edit the issue. Type should be Bug. Can this bugfix be reviewed?
  4. Ingo Muschenetz 2014-10-10

    Thank you for the PR. We will review it shortly. Since you are adding functionality, it isn't a bug, but an improvement. I've marked it as such. Thanks!
  5. Manuel Lehner 2014-10-10

    Thanks, Ingo. But isn't this a bug? (since *setHeaderView* is a documented method)
    (Uncaught TypeError: Object #<TableViewSection> has no method 'setHeaderView')
    Maybe I missed to add expected and actual result in the description. But I added a test case as comment to reproduce the bug. And since my PR actually fixes the bug it isn't really an improvement, isn't it? It simply adds the missing property accessors to give the expected result for the above test case.
  6. Eric Wieber 2015-03-12

    Verified fixed using: Titanium SDK 4.0.0.v20150312092612 Studio 4.0.0.201503062102 CLI 3.4.2 Xcode 6.2 Node 0.12 setHeaderView called without error.

JSON Source