Reputation: 387
I am implementing FlipBoard kind of view where FlipAdapter has multiple pages which has getView() in this I am adding another listview with adapter and placing onitemclickListener as shown in below code . My problem is click listener is working on the page item which is second page while the view shown is 1st page
for eg: item1 , item 2 , item 3 are in page 1 and item 4 item 5 item 6 are in page 2 . When you click on item 1 , actually item 4 is clicked which is in 2nd page .
Could not find why any help will be appreciated.
@Override public View getView(int position, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.story_list_page, parent, false);
ListView listView = (ListView) convertView
.findViewById(R.id.list_content);
listView.setVerticalScrollBarEnabled(false);
Log.d(TAG, "The current page id is " + position + "item id "
+ items.get(position).getId());
mCurrentPageAdapter = new PageListAdapter(mContext, position);
listView.setAdapter(mCurrentPageAdapter);
listView.setOnTouchListener(gestureListener);
listView.setOnItemClickListener(itemClickListener);
return convertView;
onItemCLickListner()
OnItemClickListener itemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View view,
int position, long arg3) {
Log.d("adapter", "Item clicked" + position);
ContentData item = (ContentData) mCurrentPageAdapter
.getItem(position);
Intent detailsIntent = new Intent(mContext, StoryContentActivity.class);
Log.d(TAG, "looking out for story id "+item.id);
detailsIntent.putExtra("STORY_ID", item.id);
mContext.startActivity(detailsIntent);
}
};
Upvotes: 1
Views: 231
Reputation: 18977
You pass the same position to the
mCurrentPageAdapter = new PageListAdapter(mContext, position);
in page one your intention for item 1 is one and correct but in page two the new fragment is created and so the position is also 1 and starts from beginning, so add position by number of item in each page for example in page one add by zero in page two add by all items of page one , in page three add by all items of page one and two follow the pattern.
hope help you
Upvotes: 1