if it works will be the first application.
There are about 290 items. opens a new page is clicked. but the “switch” or “if” after the error is over 250. What could be the reason?
if (position == 0) {
Intent newActivity = new Intent(this, otobus5.class);
startActivity(newActivity);
} else if (position == 1) {
Intent newActivity6 = new Intent(this, otobus6.class);
startActivity(newActivity6);
}
.
.
.
if (position == 290) {
Intent newActivity = new Intent(this, otobus290.class);
startActivity(newActivity);
} else if (position == 291) {
Intent newActivity6 = new Intent(this, otobus291.class);
startActivity(newActivity6);
}
What do these classes contain, and how do they vary? Most likely, you can have a single activity (
otobus, in this case), and simply pass the position as an extra, like so:Then, in the
onCreate()of yourotobusActivity, simply handle the layout of the activity based on the position passed: