Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old November 24th, 2011, 07:24 PM   #1 (permalink)
New Member
 
Join Date: Nov 2011
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default "onkey" search interface

Hey i want to create an edittext and a listview. this listview contains some strings, i want to be able to search these strings the same time the user enters the input

like

Cat
Dog
Monkey <-
Squirrel

when the user then types M it picks out the above and only shows that one like

--- Shows ---

Monkey

but i dont wanna search the start letter only i wanna keep searching as he types, like if he types as below it shows nothing.

--- Typed ---

Mok

--- Shows ---

nothing


i was thinking about doing in it a onTextChanged but i dont know how to make the search function, do you know if there is any tutorials out there? or do anyone know how i need to do

MrLondon is offline  
Reply With Quote
Sponsors
Old December 5th, 2011, 03:25 PM   #2 (permalink)
New Member
 
Join Date: Dec 2011
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you might need to connect to an XML document, and search there?
tkh08001 is offline  
Reply With Quote
Old December 5th, 2011, 05:38 PM   #3 (permalink)
Member
 
Join Date: Jun 2010
Posts: 363
 
Device(s): Samsung Galaxy S (international)
Thanks: 72
Thanked 57 Times in 55 Posts
Default

this is not search , what you are looking for is filtering
I did the same mistake before too, I'll try to give you some stuff from my code
at first , you'll need to have an ArrayAdapter for your list , let's call it "datasource"
and an EditText which I'll name "searchBox"

you'll also need to have a textWatcher, you can use this

Code:
    private TextWatcher filterTextWatcher = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            datasource.getFilter().filter(s);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    };
and at the end of your onCreate()
Code:
searchBox.addTextChangedListener(filterTextWatcher);
that should do it for you
__________________
if I ever said anything that helped you , the thanks button is where your cursor/finger should head to
JiMMaR is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:49 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo