Don't. Do. That.
Create a class SinglePageActivity
which takes an extra parameter page_id
:
public class SinglePageActivity extends Activity {
private int pageId;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
pageId = getIntent().getIntExtra("page_id", 1);
// You can now decide what to display depending on pageId
switch(pageId) {
case 1:
// Code for page 1
setContentView(R.layout.page_1);
break;
case 2:
// Code for page 2
setContentView(R.layout.page_2);
break;
...
}
}
public void Next(View v) {
Intent next = new Intent(this, SinglePageActivity.class);
next.putExtra("page_id", pageId + 1);
startActivity(next);
}
}
You don't have to use different layouts, but you can.
I know, this does not (exactly) answer your question. But in my opinion this is the only viable way of handling those 40 pages.
And, as we are already talking about application design, it is quite unusual to use different activites for parallel (sibling) contents. You might want to replace the content of one activity once the button is pressed.