Skip to content

Instantly share code, notes, and snippets.

@chukitow
Created January 8, 2014 18:32
Show Gist options
  • Save chukitow/8321867 to your computer and use it in GitHub Desktop.
Save chukitow/8321867 to your computer and use it in GitHub Desktop.
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