Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25660] Android: ListView 'canScroll' property cannot be set dynamically

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-01-24T00:36:50.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 7.0.2
ComponentsAndroid
LabelsListView, android
ReporterJason Kotchoff
AssigneeJoshua Quick
Created2018-01-10T23:04:26.000+0000
Updated2018-01-24T20:45:00.000+0000

Description

The 'canScroll' property on ListView for Android cannot be dynamically set. It has been implemented as a creation-only property. Please introduce a dynamic capability to run {color:red}listView.setCanScroll(false){color}; in android. This works correctly in iOS already. Test case:
var win = Ti.UI.createWindow({backgroundColor: 'black'});

var canScroll = true;

var listView = Ti.UI.createListView({
	top: 200
});
Ti.API.info("status", " canScroll " + listView.getCanScroll());
var sections = [];

var button  = Ti.UI.createButton({title: "toggle", top: 3});
win.add(button);
button.addEventListener('click', function(){
	Ti.API.info("status", " canScroll " + listView.getCanScroll());
	canScroll = !canScroll;
	listView.setCanScroll(canScroll);
	Ti.API.info("status", " canScroll " + listView.getCanScroll());
});

var fruitSection = Ti.UI.createListSection({headerTitle: 'Fruits', canScroll: false});
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'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}},
	{properties: {title: 'Potatoes'}}
];
vegSection.setItems(vegDataSet);
sections.push(vegSection);

listView.sections = sections;
win.add(listView);
win.open();

var fishSection = Ti.UI.createListSection({headerTitle: 'Fish'});
var fishDataSet = [
	{properties: {title: 'Cod'}},
	{properties: {title: 'Haddock'}}
];
fishSection.setItems(fishDataSet);
listView.appendSection(fishSection);

Comments

  1. Sharif AbuDarda 2018-01-11

    Hello, I was able to reproduce the issue in Android with SDK 7.0.1.GA. Listview "canScroll" does not work in Android, Working fine in iOS.
  2. Joshua Quick 2018-01-13

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9726 PR (7.0.X): https://github.com/appcelerator/titanium_mobile/pull/9727
  3. Lokesh Choudhary 2018-01-16

    FR Passed for both master & backport PR. Waiting for merge to become enabled.
  4. Lokesh Choudhary 2018-01-22

    Backport PR merged.
  5. Lokesh Choudhary 2018-01-24

    Master PR merged.
  6. Lokesh Choudhary 2018-01-24

    Verified the fix with SDK 7.0.2.v20180124113923 & 7.1.0.v20180124063413. Closing. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.0.2.v20180124113923, 7.1.0.v20180124063413 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.1 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1

JSON Source