Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tugas.infopendaki;
- import android.app.ListActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- public class Menu extends ListActivity {
- String classes[]={"JawaTengah","JawaBarat","JawaTimur"};
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- getListView().setBackgroundResource(tugas.infopendaki.R.drawable.peta);
- super.onCreate(savedInstanceState);
- setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
- }
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- // TODO Auto-generated method stub
- super.onListItemClick(l, v, position, id);
- String coba = classes[position];
- try {
- Class<?> ourClass = Class.forName("tugas.infopendaki." + coba);
- Intent ourIntent = new Intent(Menu.this, ourClass);
- startActivity(ourIntent);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment