Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-19200] Android: implement 'noresults' event on ListView #6987

Merged
merged 1 commit into from Jul 29, 2015

Conversation

ashcoding
Copy link
Contributor

Jira: https://jira.appcelerator.org/browse/TIMOB-19200

Test code for listview:

var win = Ti.UI.createWindow({backgroundColor: 'grey', fullscreen: true});
var search = Titanium.UI.createSearchBar({
 barColor:'#000', 
 showCancel:true,
 height:43,
 top:0,
});
search.addEventListener('cancel', function(){
    search.blur();
});
// for textSearch, use the change event to update the search value
// search.addEventListener('change', function(e){
//     listView.searchText = e.value;
// });
var listView = Ti.UI.createListView({searchView: search, caseInsensitiveSearch: true});
// for textSearch, add the search bar or text field as a header view
// var listView = Ti.UI.createListView({headerView: search, caseInsensitiveSearch: true});
var listSection = Ti.UI.createListSection();
var fruits = ['Papaya', 'Peach', 'Pear', 'Persimmon', 'Pineapple', 'Pluot', 'Pomegranate'];
var data = [];
for (var i = 0; i < fruits.length; i++) {
data.push({
    properties: {title: fruits[i], searchableText: fruits[i]}
});
}
listSection.setItems(data);
listView.addEventListener('noresults', function(e){
    alert("No results found!");
});
listView.sections = [listSection];
win.add(listView);
win.open();

Test code for tableview:

var win = Ti.UI.createWindow({
    backgroundColor: 'blue',
    fullscreen: false
});

// Use action bar search view
var search = Ti.UI.Android.createSearchView({
    hintText: "Table Search"
});

win.activity.onCreateOptionsMenu = function(e) {
    var menu = e.menu;
    var menuItem = menu.add({
        title: 'Table Search',
        actionView : search,
        icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"),
        showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
    });
};

var data = [];
data.push(Ti.UI.createTableViewRow({title:'Apple'}));
data.push(Ti.UI.createTableViewRow({title:'Banana'}));
data.push(Ti.UI.createTableViewRow({title:'Orange'}));
data.push(Ti.UI.createTableViewRow({title:'Raspberry'}));

var tableview = Titanium.UI.createTableView({
    data: data,
    search: search,
    searchAsChild: false
});

tableview.addEventListener('noresults', function(e){
    alert("No results found!");
});

win.add(tableview);
win.open();

since: "3.3.0"
platforms: [android, iphone, ipad]
since:
android: 4.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.2.0

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Looks good, just a minor comment

@ashcoding
Copy link
Contributor Author

@hieupham007 addressed comments.

@hieupham007
Copy link
Contributor

Hmm, why are you overwriting the commit? It's better to have multiple commits so we can track what is changed. Next time please don't overwrite the commit with new changes.

hieupham007 added a commit that referenced this pull request Jul 29, 2015
[TIMOB-19200] Android: implement 'noresults' event on ListView
@hieupham007 hieupham007 merged commit 15b4525 into tidev:master Jul 29, 2015
@ashcoding
Copy link
Contributor Author

Will do.

@ashcoding ashcoding deleted the TIMOB-19200 branch August 13, 2015 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants