Hammad Shahid
Hammad Shahid

Reputation: 2216

How to hide gridview in android

I have an application with One Activity and a ListView and GridView and two Buttons. When I display a GridView using button , it is displayed correctly , But when I click on ListView button to display it. It overlaps the Gridview control.

How can I handle this ? by hiding the GridView ?

Upvotes: 0

Views: 2558

Answers (1)

Stack Overflow User
Stack Overflow User

Reputation: 4082

just try this below code hide listview and show gridview:

gridshowbutton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
         // TODO Auto-generated method stub
          yourlistview.setVisibility(View.GONE);
          yourgridview.setVisibility(View.VISIBLE);
        }
});

if the click listview button try this below code:

listshowbutton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
         // TODO Auto-generated method stub
          yourlistview.setVisibility(View.VISIBLE);
          yourgridview.setVisibility(View.GONE);
        }
});

Upvotes: 4

Related Questions