package com.example.converter;

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 MenuActivity extends ListActivity {
    String[] activities;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setTitle(R.string.app_name);

        activities = getResources().getStringArray(R.array.activities);
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, activities));
    }

    public void onListItemClick(ListView parent, View v, int position,
            long id) {

        try {
            Intent i = new Intent();
            i.setClass(
                    MenuActivity.this,
                    Class.forName("com.example.converter."
                            + activities[position]));
            startActivity(i);
        }
        catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
