I am trying to manipulate the visibility of RelativeLayout
on a certain click event, using the visibility
attribute.
After adding event handlers to each list item, I can check that the visibility status is changing, but in the Android emulator, the screen doesn't change at all (and I have tested it with visibility="visible" in the XML to make sure that it would show up).
Here's the code for the click handler:
someHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater layoutSeed = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View baseView = layoutSeed.inflate(R.layout.activity_listings, null, false);
RelativeLayout popup = (RelativeLayout) baseView.findViewById(R.id.popupContainer);
Log.d("Tag1",Integer.toString(popup.getVisibility()));
popup.setVisibility(View.VISIBLE);
Log.d("Tag2",Integer.toString(popup.getVisibility()));
}
});
Logcat shows the status change. I've also tried to invalidate()
and postInvalidate()
on both baseView and popup, as well as popup.bringToFront()
and the combinations of these and so far nothing's working.
Any suggestions or possible routes to investigate?
If the RelativeLayout you are trying to change visibility is already in the screen, you don't need to inflate it again. Please make a reference to already inflated one and change its visibility
holder.relativeLayout.setVisibility(View.GONE);
Gone will remove the view from your layout. Use Invisible instead of gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With