So I have an ArrayList, and I would like to create intent and switch activities using this piece of code (in ListAdapter class):
for (int i = 0; i <= activityList.size(); i++){
if (position == i){
Intent intent = new Intent(context, (activityList.get(i).getName()).class);
context.startActivity(intent);
}
}
I am getting an 'identifier expected' error around .class.
I do have a working piece of code, that does what I want, but I have to specify the class (which isn't what I want) here:
if (position == 0) {
Intent intent = new Intent(context, NextActivity.class);
context.startActivity(intent);
}
Not exactly sure why the 1st piece of code isn't working. Any help would be greatly appreciated.