Skip to content Skip to sidebar Skip to footer

Switching Between Two Gridviews In The Same Activity

I've been looking around how to solve several problems and got several answers to some of my question, but one thing is still under construction and won't be finished if none of yo

Solution 1:

Imho you could really nicely implement a ViewFlipper to switch between your 2 Grids! From android reference guide:

ViewFlipper is a simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.

Here is an example on how to implement this. Here is another example that demonstrates this ( with animation )

Solution 2:

Why not just place both GridViews within a ViewSwitcher/ViewFlipper, and just flip between them that way?

Solution 3:

You should be able to remove the grid you don't wanna see, from app_layout and add the one you want to see. Example:

RelativeLayoutrl= (RelativeLayout) findViewById(R.id.app_layout);
GridViewgv= (GridView) findViewById(R.id.grid01); // Replace the IDGridViewgv2= (GridView) findViewById(R.id.grid02); // Replace too//...
rl.removeView(gv);
rl.addView(gv2);

// ...
rl.removeView(gv2);
rl.addView(gv);

And so on.

Post a Comment for "Switching Between Two Gridviews In The Same Activity"