Hey guys,
Been working on a project for the past year or so and it’s finally near completion. One last thing I wanted to do was to add search functionality to the table that I have (it’s an array of about 500 items, each with about 30 different data descriptions. i.e. data[1].drink = coffee, data[1].temp=hot, etc) the program mixes a bit of director, table view, and tabbar together.
Ok, so on to the problem.
I want to be able to search the table using a text field and output a tableview of relevant data. I.E. if the user searches for cof, Coffee, coffee ice cream, Coffin, etc will show up. For the purposes of my above array, I would only need to search all 500 of the data[x].drink arrays.
Thanks to the awesomeness of this community, I’ve managed to get this far:
local searchBox = native.newTextField( 200, 5, 600, 80,fieldHandler )
searchBox:setReferencePoint(display.CenterReferencePoint);
searchBox.isEditable = true;
searchBox.text = “”;
searchBox.size = 50;
local fieldHandler = function( event )
print( event.phase )
if “began” == event.phase then
– NOT SURE what to put here
searchBox.text = “”;
elseif “editing” == event.phase then
elseif “ended” == event.phase then
– NOT SURE what to put here
native.setKeyboardFocus( nil )
elseif “submitted” == event.phase then
– NOT SURE what to put here
native.setKeyboardFocus( nil )
end
end
Any advice on how to fill in the blanks would be much appreciated. Your E-Karma will be vastly increased. [import]uid: 77043 topic_id: 31396 reply_id: 331396[/import]
