1. 2015 is going to be a great year for Android! Why wait??
    Samsung Galaxy Note 5 | Samsung Galaxy S6 | HTC One M9
  2. New Forum Created: Samsung Gear VR!

OnItemClickListener Not Working


  1. assistant

    assistant Member

    Hi,

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

    My code looks something like this:

    Code:
     
    ....
     
    // Connect to database
     
    // Fill up the cursor 
     
    ....
     
     
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]textView[/COLOR][/SIZE]
    [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]
    [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]
     
    [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]adapter.setCursorToStringConverter(.....[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0]adapter.setFilterQueryProvider(...[/COLOR][/SIZE][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0]adapter.setViewBinder(...[/COLOR][/SIZE][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0]textView.setAdapter(adapter);[/COLOR][/SIZE][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0]textView.setOnItemClickListener(...[/COLOR][/SIZE][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0]...[/COLOR][/SIZE][/LEFT]
    [/COLOR][/SIZE]
    
    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

  3. assistant

    assistant Member

    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

    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 :)
Loading...

Share This Page