Here is the idea of ββcreating a level selector using the Gallery view.
Let's look at this example so that you have a code base: http://developer.android.com/resources/tutorials/views/hello-gallery.html
So, at the top you will have your level screens. When the user clicks on it, this method starts (taken directly from the example).
gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { startLevel(position); } });
Perhaps your startLevel will look something like this:
public void startLevel(int position){ Resources res = getResources(); String[] levels = res.getStringArray(R.array.level_classes); try{ Intent i = new Intent(this, Class.forName(levels[position])); startActivity(i); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
Again, a very simple example, since I have no idea how you store your levels if you use a database or not, etc. In addition, your classes for each level are likely to be in different packages (e.g. com.game.levelone, com.game.leveltwo), and you will need to import class packages so as not to get a ClassNotFoundException But this should get you started in the right direction.
Otra
source share