一定要注意在mxl中注册activity,一开始我是忘记在xml中注册activity了,花了一晚上还没有解决,
public static String[][] childStrings = { {"宋江", "林冲", "李逵", "鲁智深"}, {"曹操", "刘备", "孙权", "诸葛亮", "周瑜"}, {"贾宝玉", "林黛玉", "薛宝钗", "王熙凤"} };//设置子选项点击监听事件 expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { //childPosition代表着要接收的数组的列数 if (groupPosition==0){//groupPosition代表着要接收的数组的行数 Intent intent = new Intent(MainActivity.this, Route_detailed_activity.class); startActivity(intent); }else if (groupPosition==1){ Intent intent = new Intent(MainActivity.this, Route_detailed_activity2.class); startActivity(intent); } Toast.makeText(MainActivity.this, childStrings[groupPosition][childPosition], Toast.LENGTH_SHORT).show(); return true; } });
这样写就可以点任何一个条目去到任何一个activity都可以了。