arsiarne

list activity

Jun 16th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package tugas.infopendaki;
  2.  
  3. import android.app.ListActivity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.ArrayAdapter;
  8. import android.widget.ListView;
  9.  
  10. public class Menu extends ListActivity {
  11. String classes[]={"JawaTengah","JawaBarat","JawaTimur"};
  12.  
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. // TODO Auto-generated method stub
  16. getListView().setBackgroundResource(tugas.infopendaki.R.drawable.peta);
  17. super.onCreate(savedInstanceState);
  18. setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
  19. }
  20.  
  21. @Override
  22. protected void onListItemClick(ListView l, View v, int position, long id) {
  23. // TODO Auto-generated method stub
  24. super.onListItemClick(l, v, position, id);
  25. String coba = classes[position];
  26. try {
  27. Class<?> ourClass = Class.forName("tugas.infopendaki." + coba);
  28.  
  29. Intent ourIntent = new Intent(Menu.this, ourClass);
  30. startActivity(ourIntent);
  31.  
  32. } catch (ClassNotFoundException e) {
  33. e.printStackTrace();
  34.  
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment