[AC-6636] Android: Horizontal layout for ListViews/TableView
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Michael Gangolf |
Assignee | Abir Mukherjee |
Created | 2020-11-29T13:27:27.000+0000 |
Updated | 2020-11-29T13:28:21.000+0000 |
Description
Adding support for horizontal scrollType to ListViews and TableView:
!20201129_142049.gif!
var toggle = false;
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
title: "change",
bottom: 20
});
btn.addEventListener("click", function() {
if (!toggle) {
listView.scrollType = "horizontal"
table.scrollType = "horizontal"
listView.height = 100
table.height = 100
} else {
listView.scrollType = "vertical"
table.scrollType = "vertical"
listView.height = 300
table.height = 300
}
toggle = !toggle;
})
win.add(btn);
// ---------------- listview
var listView = Ti.UI.createListView({
top: 0,
height: 300
});
var sections = [];
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
{properties: { title: 'Apple'}},
{properties: { title: 'Banana'}},
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'});
var vegDataSet = [
{properties: { title: 'Carrots'}},
{properties: { title: 'Potatoes'}},
];
vegSection.setItems(vegDataSet);
sections.push(vegSection);
listView.sections = sections;
win.add(listView);
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish'});
var fishDataSet = [
{properties: { title: 'Cod'}},
{properties: { title: 'Haddock'}},
];
fishSection.setItems(fishDataSet);
listView.appendSection(fishSection);
// ---------------- tableview
var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'}, {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ];
var table = Ti.UI.createTableView({
data: tableData,
top: 350,
height: 300
});
win.add(table);
win.open();
Attachments
File | Date | Size |
---|---|---|
20201129_142049.gif | 2020-11-29T13:27:14.000+0000 | 378409 |
PR: https://github.com/appcelerator/titanium_mobile/pull/12301 to add even more features to the new RecyclerViews :)