Created
January 8, 2014 18:32
-
-
Save chukitow/8321867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.threads; | |
import android.app.ListActivity; | |
import android.content.Intent; | |
import android.database.DataSetObserver; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.ListAdapter; | |
import android.widget.ListView; | |
public class Menu extends ListActivity{ | |
String[] classes = {"HelloActivity","exmaples","exmaples","exmaples","exmaples"}; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
// TODO Auto-generated method stub | |
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); | |
Class ourClass; | |
try | |
{ | |
String positionSelected = classes[position]; | |
ourClass = Class.forName("com.example.threads." + positionSelected); | |
Intent i = new Intent(Menu.this,ourClass); | |
startActivity(i); | |
} | |
catch (ClassNotFoundException e) | |
{ | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment