[TIMOB-13686] Android: Implement remaining ListView v2 features (excluding search)
GitHub Issue | n/a |
---|---|
Type | Sub-task |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-10-17T21:38:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 21, 2013 Sprint 21 API, Release 3.2.0 |
Components | Android |
Labels | n/a |
Reporter | Hieu Pham |
Assignee | Hieu Pham |
Created | 2013-04-26T17:16:29.000+0000 |
Updated | 2017-03-16T22:26:20.000+0000 |
Description
Implementing the remaining ListView v2 features (excluding search and pull to refresh):
1. ListView header/footerView
2. ListSection header/footerView
4. ListView properties: separatorColor
5. ListItem properties: selectedBackgroundColor, selectedBackgroundImage, backgroundImage, backgroundGradient
Testing steps:
1. Test code for ListView header/footerView and separatorColor:
var win = Ti.UI.createWindow({backgroundColor: 'blue', fullscreen: false});
var view1 = Ti.UI.createView({height: 100, backgroundColor: "green"});
var button = Ti.UI.createButton({title: "click me"});
view1.add(button);
button.addEventListener('click', function(e) {
Ti.API.log("you clicked on button1");
});
view1.addEventListener('click', function(e) {
Ti.API.log("you clicked headerView");
});
var view2 = Ti.UI.createView({height: 100, backgroundColor: "blue"});
var button2 = Ti.UI.createButton({title: "click me"});
view2.add(button2);
button2.addEventListener('click', function(e) {
Ti.API.log("you clicked on button2");
});
view2.addEventListener('click', function(e) {
Ti.API.log("you clicked footerView");
});
var section1 = Ti.UI.createListSection();
var list = Ti.UI.createListView({separatorColor: 'blue', headerView: view1, footerView: view2, backgroundColor: 'white', sections:[section1]});
var item = {properties: {title: "hi", backgroundColor: "yellow", backgroundSelectedColor: "blue", accessoryType: 1, image: "appicon.png", color: "blue", font: {fontSize: "20sp"} }};
addItems(0, 20, item, section1);
item.properties.image = "KS_nav_ui.png";
win.add(list);
win.open();
function addItems(index, count, item, section) {
for (var i = index; i < index + count; i++) {
item.properties.title = "Label " + i;
section.appendItems([item]);
}
}
1. Run code, you should see headerView, footerView and blue separator lines.
Test case for section header/footerView and listView header/footerView:
var win = Ti.UI.createWindow({backgroundColor: 'yellow', fullscreen: false});
var view1 = Ti.UI.createView({height: '200dp', backgroundColor: "green"});
var button = Ti.UI.createButton({title: "change height to 100dp"});
view1.add(button);
button.addEventListener('click', function(e) {
Ti.API.log("you clicked on button1");
view1.height = '100dp';
});
view1.addEventListener('click', function(e) {
Ti.API.log("you clicked headerView");
});
var view2 = Ti.UI.createView({height: '200dp', backgroundColor: "red"});
var button2 = Ti.UI.createButton({title: "change height to 100dp"});
view2.add(button2);
button2.addEventListener('click', function(e) {
Ti.API.log("you clicked on button2");
view2.height = '100dp';
});
var view3 = Ti.UI.createView({height: '100dp', backgroundColor: "blue"});
var button3 = Ti.UI.createButton({title: "change height to 200dp"});
view3.add(button3);
button3.addEventListener('click', function(e) {
Ti.API.log("you clicked on button3");
view3.height = '200dp';
});
var view4 = Ti.UI.createView({height: '100dp', backgroundColor: "purple"});
var button4 = Ti.UI.createButton({title: "change height to 200dp"});
view4.add(button4);
button4.addEventListener('click', function(e) {
Ti.API.log("you clicked on button4");
view4.height = '200dp';
});
win.open();
var section1 = Ti.UI.createListSection({headerView: view1, footerView: view2});
var list = Ti.UI.createListView({headerView: view3, footerView: view4, separatorColor: 'blue', backgroundColor: 'white', sections:[section1]});
var item = {properties: {title: "hi", backgroundColor: "yellow", backgroundSelectedColor: "blue", accessoryType: 1, image: "appicon.png", color: "blue", font: {fontSize: "20sp"} }};
addItems(0, 20, item, section1);
item.properties.image = "KS_nav_ui.png";
win.add(list);
function addItems(index, count, item, section) {
for (var i = index; i < index + count; i++) {
item.properties.title = "Label " + i;
section.appendItems([item]);
}
}
1. Run code, make sure button's functionality is correct. Observe log for clicks.
Test case for selectedBackgroundImage, selectedBackgroundColor, and backgroundGradient, backgroundImage
var myTemplate1 = {
properties: {
backgroundColor: 'blue',
height: '100sp'
},
childTemplates: [
{
type: 'Ti.UI.Label',
bindId:'cellLabel',
properties: {
font: {fontSize: '12dp'},
text: "Hello"
}
}]
};
var section = Ti.UI.createListSection({headerTitle: "Header 1"});
var data = [];
for (var i = 0; i < 4; i++) {
var item = {
properties: {selectedBackgroundColor: "green"},
cellLabel: {text: "selectedBackgroundColor: green"}
};
if (i == 1) {
item.properties = {selectedBackgroundImage: "appicon.png"};
item.cellLabel.text = "selectedBackgroundImage: appicon";
} else if (i == 2) {
item.properties = {
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '50%' },
endPoint: { x: '100%', y: '50%' },
colors: [ { color: 'red', offset: 0.0}, { color: 'blue', offset: 0.25 }, { color: 'red', offset: 1.0 } ],
}
};
item.cellLabel.text = "backgroundGradient";
} else if (i==3) {
item.properties = {backgroundImage: "KS_nav_ui.png", selectedBackgroundImage: "appicon.png"};
item.cellLabel.text = "backgroundImage: KS_nav_ui, selectedBackgroundImage: appicon";
}
data.push(item);
}
section.setItems(data);
var listView = Ti.UI.createListView({defaultItemTemplate: 'myTemp', templates: {myTemp: myTemplate1}, backgroundColor: "white", sections: [section]});
var win = Ti.UI.createWindow();
win.add(listView);
win.open();
What is the status of this? We really need all the listview features done. it is such a performance boost.
master PR #1: https://github.com/appcelerator/titanium_mobile/pull/4747
Modified test code for step 1:
Test case for changing the headerView property of the listview section:
PR for selectedBackgroundColor/Image: https://github.com/appcelerator/titanium_mobile/pull/4783
Closing ticket as fixed.