class PagesAdapter extends FragmentPagerAdapter
{
public PageAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
//Return total pages, here one for each data item
return pageData.length;}
@Override
public Fragment getItem(int position) {
return null;
}
//Create the given page (indicated by position)
@Override
public Object instantiateItem(ViewGroup container, int position) {
View page = null;
page = (View) inflater.inflate(R.layout.page,null,false);
((TextView)page.findViewById (R.id.textMessage)).setText(pageData[position]);
//Add the page to the front of the queue
((ViewPager) container).addView(page, 0);
return page;
}
Error:
1-16 18:41:34.354 24761-24761/? E/AndroidRuntime: FATAL EXCEPTION: main
11-16 18:41:34.354 24761-24761/? E/Android
Runtimejava.lang.NullPointerException
11-16 18:41:34.354 24761-24761/? E/AndroidRuntime: atOnlytext $ MyPagesAdapter.instantiateItem
11-16 18:41:34.354 24761-24761/? E/AndroidRuntime:at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:870)
11-16 18:41:34.354 24761-24761/? E/AndroidRuntime: at android.support.v4.view.ViewPager.populate(ViewPager.java:1020)