- Application type: mobile
- Titanium SDK: 2.1.2
- Platform & version: Android 2.x and 4.x
- Device: Droid Incredible running 2.3.5, Samsung Galaxy something, running 4.0.something
- Host Operating System: OSX 10.8.1
- Titanium Studio: 2.1.1.201207271312
So, this is pretty simple. I've got a long-ish table ( a calendar with about 200 entries ) with TableViewSections separating events by month. On iOS I use the native TableViewSection and it works wonderfully. On Android, I also used the native approach, but it has a bug - on hidpi screens, the sections are too small to read. Way too small!
So on Android I made a custom headerView which takes DPI into account, and it looks great. Trouble is, on Android, even though I can see in my logs all the 10 or so section headers do get created, only two seem to be used. As I scroll through the table, I see the same two headers ( June and August in my test case ) repeated over and over, and not any of the other months.
It seems like the classic case of the native table APIs which save memory by re-using some minimal number of table views. But in this case, it's not useful, since it prevents section titles being shown with correct headers.
Here's my code, not that it's particularly exciting:
var section; if ( iOS ) { section = Ti.UI.createTableViewSection({ headerTitle: periodMonth.format( sectionTitlePeriodFormat ) + ' (' + periodInfo.name + ')' }) } else if ( ANDROID ) { var headerView = Ti.UI.createView({ backgroundColor: '#444', height: ShotAtLife.UI.FONT_SIZE * 2 }) var headerLabel = Ti.UI.createLabel({ text: periodMonth.format( sectionTitlePeriodFormat ) + ' (' + periodInfo.name + ')', color: '#fff', font: { fontSize: ShotAtLife.UI.FONT_SIZE, fontWeight: 'bold' }, left: PAD, right: PAD, top: 0, bottom: 0, textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT }); headerView.add( headerLabel ) section = Ti.UI.createTableViewSection({ headerView: headerView }) }
Your Answer
Think you can help? Login to answer this question!