ExpandableLayout icon indicating copy to clipboard operation
ExpandableLayout copied to clipboard

How to implement expande/collapse icon?

Open azizimusa opened this issue 10 years ago • 5 comments

How to implement icon for both expand and collapse action ?

azizimusa avatar Jun 01 '15 10:06 azizimusa

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; } }

azizimusa avatar Jun 01 '15 10:06 azizimusa

how did you manage to solve it? when I set a click listener to the expandable layout, it doesn't get called.

silviahisham avatar Nov 23 '15 03:11 silviahisham

@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

ashokslsk avatar Dec 30 '15 10:12 ashokslsk

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);
                }

            }
        });

taar1 avatar Apr 09 '16 11:04 taar1

Modify the Source Code,add a CallBack method just like OnClickListenner.

gufengpiaoyi avatar Aug 04 '16 01:08 gufengpiaoyi