开发者

Linking menus together

开发者 https://www.devze.com 2023-01-16 16:28 出处:网络
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 l

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 开发者_StackOverflow社区{

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??


Maybe its just formatting?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消