myList.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
long id) {
if (aclass == "1") {
Intent intent = new Intent(MainActivity.this, ai_ia.class);
startActivity(intent);
} else if (bclass == "2") {
Intent intent = new Intent(MainActivity.this, ai_miku.class);
startActivity(intent);
} else if (cclass == "3") {
Intent intent = new Intent(MainActivity.this, ai_nayuta.class);
startActivity(intent);
}
return false;
}
});
}
private void displayList() {
loadSomeData();
myList = (ExpandableListView) findViewById(R.id.expandableListView1);
listAdapter = new MyListAdapter(MainActivity.this, continentList);
myList.setAdapter(listAdapter);
}
private void loadSomeData() {
ArrayList<Country> ai2 = new ArrayList<Country>();
Country ai_1 = new Country("1", "11", aclass = "1");
Country ai_2 = new Country("2", "22", bclass = "2");
Country ai_3 = new Country("3", "33", cclass = "3");
ai2.add(ai_1);
ai2.add(ai_2);
ai2.add(ai_3);
Continent c1 = new Continent(R.drawable.ai_1, "ai", "(Ai)", ai2);
continentList.add(c1);
}
group은 continentList child는 ai2 입니다.
ai_1, ai_2, ai_3이 정의될 때 값을 넣어봤는데 이렇게하면 모든 값이 정의되서 같은 변수를 쓰면 마지막에 정의한 값이 변수로 들어가더라고요. (aclass = 1, aclass = 2, aclass = 3 하면 3이 나옵니다)
지금 결과는 aclass = 1, bclass = 2, cclass = 3 이라 if 가장 처음에 있는 ai_ia.class로 인텐트를 하는데요 ㅠ
여기서 대체 뭘 어떻게 하면 child item(a1_1, a1_2, a1_3) 하나하나 마다 유니크한 값을 줘서 그 값을 통해 인텐트를 시킬 수 있을까요 ?