0

I am writing an application where using ListView inside ViewPager. Here I need to get onItemClick for list item click but it's not working.

Any suggestion here, is there anything we need to maintain while using ListView inside ViewPager?

TooCool
  • 10,598
  • 15
  • 60
  • 85
CoDe
  • 11,056
  • 14
  • 90
  • 197
  • you can check this : http://stackoverflow.com/questions/15189316/listfragments-inside-viewpager – TooCool Dec 09 '14 at 10:01
  • Thanks...but it will not work in my case...Since I have some other component along side ListView to use. – CoDe Dec 09 '14 at 10:06

1 Answers1

0

In ViewPager, you must be using fragments. In any of those fragments, you can register onItemClick event for a listview.

TechHelper
  • 822
  • 10
  • 24
  • yes that is obvious choice to implement ViewPager with FragmentAdapter in this case. But some how itemClickListener not working. – CoDe Dec 09 '14 at 09:56
  • post your code where you have registered that event – TechHelper Dec 09 '14 at 09:58
  • dear...it;s same like generally we do : lstView.setOnItemClickListener(context); inside Fragment(View pager child). – CoDe Dec 09 '14 at 10:00
  • check if context is correct. it should be OnItemClickListener interface. – TechHelper Dec 09 '14 at 10:05
  • yes it is there and since then only I could able to check at runtime. – CoDe Dec 09 '14 at 10:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66461/discussion-between-shubh-and-techhelper). – CoDe Dec 09 '14 at 10:11
  • try this:yourList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) { onClick(arg2); } }); – Ebin James Dec 09 '14 at 10:17