Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.app.ListActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuInflater;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- public class CurrentMobs extends ListActivity {
- private static final int ACTIVITY_0 = 0;
- private static final int ACTIVITY_1 = 1;
- private static final int ACTIVITY_2 = 2;
- private static final int ACTIVITY_3 = 3;
- private static final int ACTIVITY_4 = 4;
- private static final int ACTIVITY_5 = 5;
- private static final int ACTIVITY_6 = 6;
- private static final int ACTIVITY_7 = 7;
- private static final int ACTIVITY_8 = 8;
- private static final int ACTIVITY_9 = 9;
- private static final int ACTIVITY_10 = 10;
- private static final int ACTIVITY_11 = 11;
- private static final int ACTIVITY_12 = 12;
- private static final int ACTIVITY_13 = 13;
- private static final int ACTIVITY_14 = 14;
- private static final int ACTIVITY_15 = 15;
- private static final int ACTIVITY_16 = 16;
- private static final int ACTIVITY_17 = 17;
- private static final int ACTIVITY_18 = 18;
- private static final int ACTIVITY_19 = 19;
- private static final int ACTIVITY_20 = 20;
- private static final int ACTIVITY_21 = 21;
- static final String[] MOBILE_OS =
- new String[] { "Bat", "Blaze", "Cave Spider", "Creeper", "Ender Dragon", "Enderman", "Ghast", "Iron Golem", "Magma Cube", "Silverfish", "Skeleton", "Slime", "Snow Golem", "Spider", "Spider Jockey", "Villager", "Witch", "Wither", "Wither Skeleton", "Zombie", "Zombie Pigman", "Zombie Villager"};
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setListAdapter(new MobileArrayAdapter(this, MOBILE_OS));
- }
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- //get selected items
- String selectedValue = (String) getListAdapter().getItem(position);
- super.onListItemClick(l, v, position, id);
- final Intent intent = new Intent();
- // Set up different intents based on the item clicked:
- switch (position)
- {
- case ACTIVITY_0:
- intent.setClass(this, Bat.class);
- break;
- case ACTIVITY_1:
- intent.setClass(this, Blaze.class);
- break;
- case ACTIVITY_2:
- intent.setClass(this, CaveSpider.class);
- break;
- case ACTIVITY_3:
- intent.setClass(this, Creeper.class);
- break;
- case ACTIVITY_4:
- intent.setClass(this, EnderDragon.class);
- break;
- case ACTIVITY_5:
- intent.setClass(this, Endermen.class);
- break;
- case ACTIVITY_6:
- intent.setClass(this, Ghast.class);
- break;
- case ACTIVITY_7:
- intent.setClass(this, IronGolem.class);
- break;
- case ACTIVITY_8:
- intent.setClass(this, MagmaCube.class);
- break;
- case ACTIVITY_9:
- intent.setClass(this, SilverFish.class);
- break;
- case ACTIVITY_10:
- intent.setClass(this, Skeleton.class);
- break;
- case ACTIVITY_11:
- intent.setClass(this, Slime.class);
- break;
- case ACTIVITY_12:
- intent.setClass(this, SnowGolem.class);
- break;
- case ACTIVITY_13:
- intent.setClass(this, Spider.class);
- break;
- case ACTIVITY_14:
- intent.setClass(this, SpiderJockey.class);
- break;
- case ACTIVITY_15:
- intent.setClass(this, Villager.class);
- break;
- case ACTIVITY_16:
- intent.setClass(this, Witch.class);
- break;
- case ACTIVITY_17:
- intent.setClass(this, Wither.class);
- break;
- case ACTIVITY_18:
- intent.setClass(this, WitherSkeleton.class);
- break;
- case ACTIVITY_19:
- intent.setClass(this, Zombie.class);
- break;
- case ACTIVITY_20:
- intent.setClass(this, ZombiePigman.class);
- break;
- case ACTIVITY_21:
- intent.setClass(this, ZombieVillager.class);
- break;
- }
- // Pass the item position as the requestCode parameter, so on the `Activity`'s
- // return you can examine it, and determine which activity were you in prior.
- startActivityForResult(intent, position);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- inflater.inflate(R.menu.options, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.statistics:
- Intent intent0 = new Intent(CurrentMobs.this, Statistics.class);
- startActivity(intent0);
- return true;
- case R.id.funfacts:
- Intent intent1 = new Intent(CurrentMobs.this, FunFacts.class);
- startActivity(intent1);
- return true;
- case R.id.home:
- Intent intent2 = new Intent(CurrentMobs.this, Home.class);
- startActivity(intent2);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment