Guest User

Untitled

a guest
Nov 4th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1.  
  2. import android.app.ListActivity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.view.Menu;
  6. import android.view.MenuInflater;
  7. import android.view.MenuItem;
  8. import android.view.View;
  9. import android.widget.ArrayAdapter;
  10. import android.widget.ListView;
  11.  
  12. public class CurrentMobs extends ListActivity {
  13.  
  14. private static final int ACTIVITY_0 = 0;
  15. private static final int ACTIVITY_1 = 1;
  16. private static final int ACTIVITY_2 = 2;
  17. private static final int ACTIVITY_3 = 3;
  18. private static final int ACTIVITY_4 = 4;
  19. private static final int ACTIVITY_5 = 5;
  20. private static final int ACTIVITY_6 = 6;
  21. private static final int ACTIVITY_7 = 7;
  22. private static final int ACTIVITY_8 = 8;
  23. private static final int ACTIVITY_9 = 9;
  24. private static final int ACTIVITY_10 = 10;
  25. private static final int ACTIVITY_11 = 11;
  26. private static final int ACTIVITY_12 = 12;
  27. private static final int ACTIVITY_13 = 13;
  28. private static final int ACTIVITY_14 = 14;
  29. private static final int ACTIVITY_15 = 15;
  30. private static final int ACTIVITY_16 = 16;
  31. private static final int ACTIVITY_17 = 17;
  32. private static final int ACTIVITY_18 = 18;
  33. private static final int ACTIVITY_19 = 19;
  34. private static final int ACTIVITY_20 = 20;
  35. private static final int ACTIVITY_21 = 21;
  36.  
  37. static final String[] MOBILE_OS =
  38. 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"};
  39.  
  40. @Override
  41. public void onCreate(Bundle savedInstanceState) {
  42. super.onCreate(savedInstanceState);
  43.  
  44. setListAdapter(new MobileArrayAdapter(this, MOBILE_OS));
  45. }
  46.  
  47. @Override
  48. protected void onListItemClick(ListView l, View v, int position, long id)
  49.  
  50. {
  51. //get selected items
  52. String selectedValue = (String) getListAdapter().getItem(position);
  53. super.onListItemClick(l, v, position, id);
  54. final Intent intent = new Intent();
  55. // Set up different intents based on the item clicked:
  56. switch (position)
  57. {
  58. case ACTIVITY_0:
  59. intent.setClass(this, Bat.class);
  60. break;
  61. case ACTIVITY_1:
  62. intent.setClass(this, Blaze.class);
  63. break;
  64. case ACTIVITY_2:
  65. intent.setClass(this, CaveSpider.class);
  66. break;
  67. case ACTIVITY_3:
  68. intent.setClass(this, Creeper.class);
  69. break;
  70. case ACTIVITY_4:
  71. intent.setClass(this, EnderDragon.class);
  72. break;
  73. case ACTIVITY_5:
  74. intent.setClass(this, Endermen.class);
  75. break;
  76. case ACTIVITY_6:
  77. intent.setClass(this, Ghast.class);
  78. break;
  79. case ACTIVITY_7:
  80. intent.setClass(this, IronGolem.class);
  81. break;
  82. case ACTIVITY_8:
  83. intent.setClass(this, MagmaCube.class);
  84. break;
  85. case ACTIVITY_9:
  86. intent.setClass(this, SilverFish.class);
  87. break;
  88. case ACTIVITY_10:
  89. intent.setClass(this, Skeleton.class);
  90. break;
  91. case ACTIVITY_11:
  92. intent.setClass(this, Slime.class);
  93. break;
  94. case ACTIVITY_12:
  95. intent.setClass(this, SnowGolem.class);
  96. break;
  97. case ACTIVITY_13:
  98. intent.setClass(this, Spider.class);
  99. break;
  100. case ACTIVITY_14:
  101. intent.setClass(this, SpiderJockey.class);
  102. break;
  103. case ACTIVITY_15:
  104. intent.setClass(this, Villager.class);
  105. break;
  106. case ACTIVITY_16:
  107. intent.setClass(this, Witch.class);
  108. break;
  109. case ACTIVITY_17:
  110. intent.setClass(this, Wither.class);
  111. break;
  112. case ACTIVITY_18:
  113. intent.setClass(this, WitherSkeleton.class);
  114. break;
  115. case ACTIVITY_19:
  116. intent.setClass(this, Zombie.class);
  117. break;
  118. case ACTIVITY_20:
  119. intent.setClass(this, ZombiePigman.class);
  120. break;
  121. case ACTIVITY_21:
  122. intent.setClass(this, ZombieVillager.class);
  123. break;
  124. }
  125. // Pass the item position as the requestCode parameter, so on the `Activity`'s
  126. // return you can examine it, and determine which activity were you in prior.
  127. startActivityForResult(intent, position);
  128.  
  129. }
  130. @Override
  131. public boolean onCreateOptionsMenu(Menu menu) {
  132. MenuInflater inflater = getMenuInflater();
  133. inflater.inflate(R.menu.menu, menu);
  134. inflater.inflate(R.menu.options, menu);
  135. return true;
  136. }
  137. @Override
  138. public boolean onOptionsItemSelected(MenuItem item) {
  139. // Handle item selection
  140. switch (item.getItemId()) {
  141. case R.id.statistics:
  142. Intent intent0 = new Intent(CurrentMobs.this, Statistics.class);
  143. startActivity(intent0);
  144. return true;
  145. case R.id.funfacts:
  146. Intent intent1 = new Intent(CurrentMobs.this, FunFacts.class);
  147. startActivity(intent1);
  148. return true;
  149. case R.id.home:
  150. Intent intent2 = new Intent(CurrentMobs.this, Home.class);
  151. startActivity(intent2);
  152. return true;
  153. default:
  154. return super.onOptionsItemSelected(item);
  155. }
  156. }
  157.  
  158.  
  159. }
Advertisement
Add Comment
Please, Sign In to add comment