Sorry for the formating errors – How do you use position once you have it (or another variable for that matter) to activate a file or other task? For example I want to use position 1 to open screen1.java and position 2 to open screen2.java. I could use if/else statements but can I do it in one line rather than many? If I had 100 different screens then an if then statement would be silly. Here is what I have as an (incorrect) example. Can you help me correct it?
public void onItemClick(AdapterView<?> parent, View v,
int position, long id){
//opens relevant game window
Intent intent = new Intent(context, "game"+(position)+"mainscreen"+".class");
startActivity(intent);
}
});
}
TO SUMMARIZE:-
instead of using game1mainscreen.class I want to use something like “game”+(position)+”mainscreen”+”.class”
You can define intent filter for your activities in AndroidManifest.xml file as follows
and after that use following code to start your game activity