Try changing destroyItem to this:
@Override
public void destroyItem(View arg0, int arg1, Object arg2){
((ViewPager) arg0).removeViewAt(arg1);
}
and isViewFromObject to:
@Override
public boolean isViewFromObject(View view, Object object){
return view.equals(object);
}
If these changes dont work then I suggest u check what happens after u can "findViewById" on the collection View. It looks like the button u are looking is not within that object. You have to search for it in the view you are inflating.
Try this code for your instantiation code:
@Override
public Object instantiateItem(View collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId = 0;
View view = null;
switch (position) {
case 0:
view = inflater.inflate(R.layout.splash2, null);
b = (Button) view.findViewById(R.id.splashB);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//setContentView(r.layout.someLayout);
}
});
break;
case 1:
view = inflater.inflate(R.layout.splash3, null);
break;
case 2:
view = inflater.inflate(R.layout.splash4, null);
break;
case 3:
view = inflater.inflate(R.layout.splash5, null);
break;
}
((ViewPager) collection).addView(view, 0);
return view;
}