At the moment I have a custom PagerAdapter class in my android app that basically gives a new flash card for each swipe using cursors. At the beginning it gives a custom XML that would basically give instructions (swipe left for previous, right for next). After it has been swiped to the right it will then move onto the flash cards and cycle through them as the person swipes. What I want to do is two things:
1)At the end of the ViewPager (after the cursor has reached its last position and the user has seen the last card) I want to append a custom XML View just as I did at the beginning.
2)I would like to make the ViewPager stop at at this view and make it so further swipes to the right won't do anything.
At the moment 1) is very important and has been frustrating me to no end. 2) I can live without but would be handy to know for future references. I've written out my code below is hopefully some Android/ViewPager/PagerAdapter experts can help me out. Thanks for your help!
@Override
public Object instantiateItem(View view, int position) {
LinearLayout layout = null;
int position2 = position;
if(position == 0){
layout = (LinearLayout) inflater.inflate(R.layout.activity_slide_info, null);
}else{
position2--;
cursor.moveToPosition(position2);
layout = (LinearLayout) inflater.inflate(R.layout.activity_card, null);
TextView cardTitle = (TextView) layout.findViewById(R.id.pirate_card_title);
TextView cardExample = (TextView) layout.findViewById(R.id.pirate_card_example);
TextView cardDefinition = (TextView) layout.findViewById(R.id.pirate_card_definition);
cardTitle.setText(cursor.getString(cursor.getColumnIndex(FlashCardTable.COLUMN_TITLE)));
cardExample.setText(cursor.getString(cursor.getColumnIndex(FlashCardTable.COLUMN_SENTENCE)));
cardDefinition.setText(cursor.getString(cursor.getColumnIndex(FlashCardTable.COLUMN_DEFINITION)));
}
((ViewPager) view).addView(layout);
return layout;
}