Code example for ViewPager.SimpleOnPageChangeListener

			return fragments.size();
	// nested class is responsible for notifying when a new quote is displayed 
	private class QuotePageChangeListener extends SimpleOnPageChangeListener { 
		public void onPageSelected(int position) {
			// update quote index display 
			quoteIndex.setText((position + 1) + "/" + quoteFragments.size());
	// adds current quote to a list of favorites (carried out by ParseXmlQuotes class) 
	public void addFavorite(View view) throws IOException {
		String added = "Added to Favorites";
		String removed = "Removed from Favorites";
		if (ParseXmlQuotes.addToFavorites(getCurrentQuote().getId(), getApplicationContext())) 
			toast = Toast.makeText(getApplicationContext(), added, Toast.LENGTH_SHORT);
Contextual code suggestions in your IDE  Get Codota for Java