Search code examples
androidadapterandroid-listfragment

Endless adapter onclick event


I'm trying to use the endless adapter in a list fragment context. Everything is working pretty fine except for the click events on any of the item.

  • If the fragment is implementing onclicklistener, nothing happens in onclick

  • If the fragment is implementing onitemclicklistener, nothing happens in onitemclick

  • If I override onListItemclick, I never get any response.

  • Adding an "android:onClick" in the item xml layout, crash the app with a "can't found your public void thing(View v) function in android.app.Application" (don't knwo why it's not looking in my fragment or my activity where I tried to declare it).

I ended making a setClickListener in the endless adapter. But the event is intercepted in the endless adapter and I must propagage it to my fragment which makes this solution really ugly.

Any hint ?


Solution

  • Found it...

    @Override
    public void onStart() {
        super.onStart();
        getListView().setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            }
        });
    }