Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6636] Android: Horizontal layout for ListViews/TableView

GitHub Issuen/a
TypeImprovement
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterMichael Gangolf
AssigneeAbir Mukherjee
Created2020-11-29T13:27:27.000+0000
Updated2020-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

FileDateSize
20201129_142049.gif2020-11-29T13:27:14.000+0000378409

Comments

  1. Michael Gangolf 2020-11-29

    PR: https://github.com/appcelerator/titanium_mobile/pull/12301 to add even more features to the new RecyclerViews :)

JSON Source