1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

OnItemClickListener Not Working


Last Updated:

  1. assistant

    assistant Member This Topic's Starter

    Joined:
    Feb 20, 2011
    Messages:
    9
    Likes Received:
    0
    Hi,

    Problem is that onItemClickListener it's not working and it's not throwing any exceptions.

    My code looks something like this:

    Code (Text):
    1.  
    2.  
    3. ....
    4.  
    5. // Connect to database
    6.  
    7. // Fill up the cursor
    8.  
    9. ....
    10.  
    11.  
    12. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]textView[/COLOR][/SIZE]
    13. [LEFT][/COLOR][/SIZE][SIZE=2]= (AutoCompleteTextView) findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]autocomplete_users[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    14. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]adapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] SimpleCursorAdapter([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]list_item[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], cursor, from, to);[/SIZE][/LEFT]
    15.  
    16. [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]adapter.setCursorToStringConverter(.....[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][/LEFT]
    17.  
    18. [LEFT][SIZE=2][COLOR=#0000c0]adapter.setFilterQueryProvider(...[/COLOR][/SIZE][/LEFT]
    19.  
    20. [LEFT][SIZE=2][COLOR=#0000c0]adapter.setViewBinder(...[/COLOR][/SIZE][/LEFT]
    21.  
    22. [LEFT][SIZE=2][COLOR=#0000c0]textView.setAdapter(adapter);[/COLOR][/SIZE][/LEFT]
    23.  
    24. [LEFT][SIZE=2][COLOR=#0000c0]textView.setOnItemClickListener(...[/COLOR][/SIZE][/LEFT]
    25.  
    26. [LEFT][SIZE=2][COLOR=#0000c0]...[/COLOR][/SIZE][/LEFT]
    27. [/COLOR][/SIZE]
    28.  
    The items(sugestions) in a autocomplete drop down list are generated dinamically, based on entered search criteria.​

    When certain item gets clicked nothing happens. :confused:

    Any sugestions?​

    Best regards.​
     

    Advertisement
  2. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
  3. assistant

    assistant Member This Topic's Starter

    Joined:
    Feb 20, 2011
    Messages:
    9
    Likes Received:
    0
    Hi Alostpacket,

    Thanks for your try.

    The solution is to set OnItemClickListener under onStart() method not under onCreate(). Why is that so, I don't know yet but it's working. ;)
     
  4. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Joined:
    Nov 29, 2009
    Messages:
    7,978
    Likes Received:
    3,603
    no problem, that's pretty weird though. I mean theorectically you should be able to set and change listeners whenever you need to. It's the whole "de-coupling" idea behind having a separate listener in the first place...

    Strange.


    Glad it's working for you though :)
     

Share This Page

Loading...