ExpandableCardView icon indicating copy to clipboard operation
ExpandableCardView copied to clipboard

How to access the items inside the expanded layout

Open venkyvc opened this issue 5 years ago • 7 comments

Hey...!! I created an expanded layout from your library and everything went fine but I want to know how can I access those view fields. Example how can I set the click listener for a button in the exapanded layout.

venkyvc avatar Feb 08 '20 05:02 venkyvc

I used reflection. Dirty trick but does the work until we have a reply.

    cardView = itemView.findViewById(R.id.card);
    try {
        Field innerViewField = ExpandableCardView.class.getDeclaredField("innerView");
        innerViewField.setAccessible(true);
        View innerView = (View) innerViewField.get(cardView);
    }
    catch (Exception ex){
        Log.e("reflaction failed",ex.getMessage(),ex);
    }

petruscurtu avatar May 19 '20 08:05 petruscurtu

I Have the same issue I want to access inner layout and their fields plz reply asap

0230 avatar Sep 21 '20 09:09 0230

me too have the same problem, please tell me how to access id inner view

mitf avatar Jan 19 '21 08:01 mitf

Hello, you will be able to access the innerView and its fields using the findViewById method. Let's say you have a custom_button view inflated inside the ExplandableCardView.

In order to get the reference to that button you do this:

View innerView = explandableCardView.findViewById(R.id.innerView);
Button myButton = innerView.findViewById(R.id.custom_button);

Kind regards :)

AleSpero avatar Jan 19 '21 09:01 AleSpero

Hello, you will be able to access the innerView and its fields using the findViewById method. Let's say you have a custom_button view inflated inside the ExplandableCardView.

In order to get the reference to that button you do this:

View innerView = explandableCardView.findViewById(R.id.innerView);
Button myButton = innerView.findViewById(R.id.custom_button);

Kind regards :)

how can i achieve this using viewbinding ?

Pify avatar Feb 11 '21 13:02 Pify

Hello, you will be able to access the innerView and its fields using the findViewById method. Let's say you have a custom_button view inflated inside the ExplandableCardView. In order to get the reference to that button you do this:

View innerView = explandableCardView.findViewById(R.id.innerView);
Button myButton = innerView.findViewById(R.id.custom_button);

Kind regards :)

how can i achieve this using viewbinding ?

val innerView = expandableCardView.findViewById<View>(R.id.innerView)
val binding = LayoutBinding.bind(innerView)

This one works for me

BryanMambo avatar Mar 23 '21 10:03 BryanMambo

Hello, you will be able to access the innerView and its fields using the findViewById method. Let's say you have a custom_button view inflated inside the ExplandableCardView. In order to get the reference to that button you do this:

View innerView = explandableCardView.findViewById(R.id.innerView);
Button myButton = innerView.findViewById(R.id.custom_button);

Kind regards :)

how can i achieve this using viewbinding ?

val innerView = expandableCardView.findViewById<View>(R.id.innerView)
val binding = LayoutBinding.bind(innerView)

This one works for me

nice info, thanks

myaasiinh avatar Aug 07 '22 00:08 myaasiinh