ExpandableCardView
ExpandableCardView copied to clipboard
How to access the items inside the expanded layout
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.
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);
}
I Have the same issue I want to access inner layout and their fields plz reply asap
me too have the same problem, please tell me how to access id inner view
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 :)
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 ?
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
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