ExpandableCardView
                                
                                
                                
                                    ExpandableCardView copied to clipboard
                            
                            
                            
                        expand and collapse problem
Hi, I have 2 cardviews. If I click the first card view, I would like to expand this card view and to collapse the second card view. By the same way, if I click the second card view, I would like to expand this card view and to collapse the first card view,
Unfortunately, the card view that I want to collapse is disappearing from the screen. and it is not reachable again. please help me for solving this problem.
card1 = root.findViewById(R.id.x1); card2 = root.findViewById(R.id.x2);
    card1.setOnExpandedListener(new ExpandableCardView.OnExpandedListener() {
        @Override
        public void onExpandChanged(View v, boolean isExpanded) {
            
            if (isExpanded)
                card2.collapse();
        }
    });
    card2.setOnExpandedListener(new ExpandableCardView.OnExpandedListener() {
        @Override
        public void onExpandChanged(View v, boolean isExpanded) {
            
            if(isExpanded)
                card1.collapse();
        }
    });
                                    
                                    
                                    
                                
I have the same problem. Is this issue solved?
Hi @princeivankent, I solved this problem. You need to expand cardviews by giving a delay at first. I am adding code below.
private void cardViewListeners() {
    try {
        new Handler().postDelayed(() -> binding.cardView1.expand(), 100);
        new Handler().postDelayed(() -> binding.cardView2.expand(), 100);
        binding.cardView1.setOnExpandedListener((v, isExpanded) -> {
            if (isExpanded) {
                new Handler().postDelayed(() -> {
                    binding.cardView2.collapse();
                }, 100);
            }
        });
        binding.cardView2.setOnExpandedListener((v, isExpanded) -> {
            if (isExpanded) {
                new Handler().postDelayed(() -> {
                    binding.cardView1.collapse();
                }, 30);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
                                    
                                    
                                    
                                
handed this, check the card is expanded before the collapse
             if (card2.isExpanded) {
                 card2.collapse()
             }`
                                    
                                    
                                    
                                
I'm having same problem