How to implement expande/collapse icon?
How to implement icon for both expand and collapse action ?
i solve it by using layout android:onClick and then on activity, check if element is opened or not. then implement drawable of both condition.
// LAYOUT android:focusableInTouchMode="false" android:onClick="checkExpand" android:tag="saving" android:focusable="false"
// ACTIVITY public void checkExpand(View v){ String tag = (String) v.getTag(); ExpandableLayout EL2 = (ExpandableLayout) findViewById(R.id.EL_saving); ImageView IC2 = (ImageView) findViewById(R.id.ic_saving);
switch (tag){ case "saving": if(!EL2.isOpened()){ EL2.show(); IC2.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_collapse)); } else { EL2.hide(); IC2.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_expand)); } break; } }
how did you manage to solve it? when I set a click listener to the expandable layout, it doesn't get called.
@silviahisham @azizimusa Please close this issue so that people using this library can make use of the following code. And for some reason @azizimusa code did not work well for me so i did something like this and its working super fine and looks super cool.
:+1:
Check this gist i have created for you. Link : https://gist.github.com/ashokslsk/4dcd9675b6e4b8436874
This is how I solved this problem:
bodyFeaturesLayout.getHeaderLayout().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bodyFeaturesLayout.isOpened()) {
bodyFeaturesLayout.hide();
bodyFeaturesRightIcon.setImageResource(R.drawable.ic_expand_more_black_36dp);
} else {
bodyFeaturesLayout.show();
bodyFeaturesRightIcon.setImageResource(R.drawable.ic_expand_less_black_36dp);
}
}
});
Modify the Source Code,add a CallBack method just like OnClickListenner.