You are probably clicking on the result list. In that case you are in
touch mode and the selection does not exist in the drop down. Instead
of calling parent.getSelected*() you should call obtainItem(int
position).

On Mon, Mar 31, 2008 at 5:30 PM, Max Binshtok <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>
>  I have a problem with AutoCompleteTextView
>
>  I have a (clickable) list of objects i.e. when you click on an item
>  you get to another activity which is guided by that specific item
>  clicked. I want to use the Autocomplete to search in that list but I
>  want the same behavior I get with a regular list - an item to be
>  clicked and processed. Please see my code:
>
>
>
>         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
>                 android.R.layout.simple_list_item_1, namesLIST);
>         AutoCompleteTextView textView = (AutoCompleteTextView)
>  findViewById(R.id.list);
>
>         textView.setAdapter(adapter);
>
>  Where namesLIST is a String array created specially for the
>  Autocomplete
>
>  Then I do:
>                 textView.setOnItemClickListener(new OnItemClickListener() {
>                         public void onItemClick(AdapterView parent, View v, 
> int position,
>  long id) {
>                                 showItem(parent,position, id);
>                         }
>                 });
>
>  where I tried to see what I get:
>
>         private void showItem(AdapterView parent, int position, long id) {
>                 Log.d(TAG,"zz position:" + parent.getSelectedItemPosition());
>                 Log.d(TAG,"selected item:" +parent.getSelectedItem());
>                 Log.d(TAG,"adapter view:" + parent);
>                 Log.d(TAG,"position:" + position + " id:" +id);
>         }
>
>  I saw that I get nothing useful here. Typical output would be:
>  zz position: -1
>  selected item: null
>  adapter view: .....
>  position: 1 id:1
>
>  What am I doing wrong? How can I keep the reference to original items
>  in the original list?
>  Maybe I can I use the original objects somehow in Autocomplete?
>
>
>  Thank you for your help!
>  >
>



-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to