Thanks! Yeah, sure, that's acutally quite easy! You could just add text2.setVisibility(View.GONE); button2.setImageResource(R.drawable.ic_arrow_down); to the if statement of button1.setOnClickListener and text1.setVisibility(View.GONE); button1.setImageResource(R.drawable.ic_arrow_down); to the if statement of button1.setOnClickListener, respectively. So the whole part would be: button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (text1.getVisibility() == View.GONE) { text1.setVisibility(View.VISIBLE); button1.setImageResource(R.drawable.ic_arrow_up); text2.setVisibility(View.GONE); button2.setImageResource(R.drawable.ic_arrow_down); } else { text1.setVisibility(View.GONE); button1.setImageResource(R.drawable.ic_arrow_down); } } }); button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (text2.getVisibility() == View.GONE) { text2.setVisibility(View.VISIBLE); button2.setImageResource(R.drawable.ic_arrow_up); text1.setVisibility(View.GONE); button1.setImageResource(R.drawable.ic_arrow_down); } else { text2.setVisibility(View.GONE); button2.setImageResource(R.drawable.ic_arrow_down); } } }); Hope that helps!
Precise and to the point. We need more guys like you, I'm subscribing right now!
Thanks! Really happy to get feedback like that!
Thank you very much
very helpfull video love from bangladesh
Precise and to the point. Thank you
Would it be possible to automatically collapse one heading if another is clicked to avoid long scrolls?
Thanks!
Yeah, sure, that's acutally quite easy! You could just add
text2.setVisibility(View.GONE);
button2.setImageResource(R.drawable.ic_arrow_down);
to the if statement of button1.setOnClickListener and
text1.setVisibility(View.GONE);
button1.setImageResource(R.drawable.ic_arrow_down);
to the if statement of button1.setOnClickListener, respectively.
So the whole part would be:
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (text1.getVisibility() == View.GONE) {
text1.setVisibility(View.VISIBLE);
button1.setImageResource(R.drawable.ic_arrow_up);
text2.setVisibility(View.GONE);
button2.setImageResource(R.drawable.ic_arrow_down);
} else {
text1.setVisibility(View.GONE);
button1.setImageResource(R.drawable.ic_arrow_down);
}
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (text2.getVisibility() == View.GONE) {
text2.setVisibility(View.VISIBLE);
button2.setImageResource(R.drawable.ic_arrow_up);
text1.setVisibility(View.GONE);
button1.setImageResource(R.drawable.ic_arrow_down);
} else {
text2.setVisibility(View.GONE);
button2.setImageResource(R.drawable.ic_arrow_down);
}
}
});
Hope that helps!
Very helpful. Thanks a lot.
Glad to help :)
Hello, not working in Koala versión. I copy your code exactly, app run but no show any error.
Very nice 👍🏻👍🏻🙂
helpful, thanks
where i can email you ? i have some question