views:

34

answers:

1

Hi, I am really struggling with linking menus together. The app I want to create is a collection of menus that leads to url links to various sites I plan to open within the application. I have created a list activity menu with 8 options and I have eight classes with further options. My problem is how to link the menus together. I ask the question and someone said that I should map. Here is the code:

public class MyList extends ListActivity {

private static final String Cp = null;
private static final String Pp = null;
private static final String L2 = null;
private static final String L1 = null;
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // Create an array of Strings, that will be put to our ListActivity
    String[] names = new String[] { "Pp", "Cp", "L1", "L2", "Bt", "Se", "As", "Travel"};
    // Create an ArrayAdapter, that will actually make the Strings above
    // appear in the ListView
    this.setListAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_checked, names));
}
{Map<String, Runner> runners = new HashMap<String, Runner>();
runners.put("Pp", (Runner) new Pp());
runners.put("Cp", (Runner) new Cp());
runners.put("L1", (Runner) new L1());
runners.put("L2", (Runner) new L2());


public void onListItemClick(runners.get(getListView()).L2();
runners.get(getListView()).L1();
runners.get(getListView()).Pp();
runners.get(getListView()).Cp(); {

I have setup a class called runners and added the next menu within each option like so:

public interface Runner {

void L2();

void L1();

void Pp();

void Cp();
}

At the moment I get one error at this line public void onListItemClick(runners.get(getListView()).League2(); void is an invalid type for the variable onListItemClick, have I done this correctly, am I missing something, is this the way I should use this method??

A: 

Maybe its just formatting?

public void onListItemClick() { runners.get(getListView()).L2(); runners.get(getListView()).L1(); runners.get(getListView()).Pp(); runners.get(getListView()).Cp(); }

sandlex