Open lovingnirav opened 7 years ago
Hi @lovingnirav , you can get the subitem view by calling the method getSubItemView
of ExpandingItem object. Then, you can set the click listener on that view.
Please check the example code here: https://github.com/diegodobelo/AndroidExpandingViewLibrary/blob/master/example/src/main/java/com/diegodobelo/expandinganimlib/MainActivity.java#L67
You just have to do something like:
final View view = item.getSubItemView(i);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// perform action
}
});
On line 41
addItem("John", new String[]{"House", "Boat", "Candy", "Collection", "Sport", "Ball", "Head"}, R.color.pink, R.drawable.ic_ghost);
How would you set different action for different subitem
Example i want to start Activity1 on House click and Activity2 to open on Boat click Activity 3 to open on Candy click and so on..
On line 96 you may replace the code by:
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (subTitle.equals("House")) {
startActivity(new Intent(MainActivity.this, HouseActivity.class));
} else if (subTitle.equals("Boat")) {
startActivity(new Intent(MainActivity.this, BoatActivity.class));
}
...
}
});
Thanks it worked .... One more question what if their are two same subTitle in different Title, how do i set different actions ?? Example
addItem("John", new String[]{"House", "Boat"}, R.color.pink, R.drawable.ic_ghost);
addItem("Mary", new String[]{"House", "Boat"}, R.color.blue, R.drawable.ic_ghost);
How to add OnclickListener to subitem ?