Can anyone help me to find out what can be the issue with this program.
In the onCreate()
method the findViewById()
returns null for all ids and th
The views you're trying to get are not defined in your activity_main
layout. You need to programmatically inflate the views you're trying to add to the pager.-
@Override
public Object instantiateItem(ViewGroup collection, int position) {
LinearLayout l = null;
if (position == 0) {
l = (LinearLayout) View.inflate(this, R.layout.activity_first, null);
}
if (position == 1) {
l = (LinearLayout) View.inflate(this, R.layout.activity_second, null);
}
if (position == 2) {
l = (LinearLayout) View.inflate(this, R.layout.activity_third, null);
}
collection.addView(l, position);
return l;
}