Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4541700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:16:45+00:00 2026-05-21T15:16:45+00:00

I’ve been looking around how to solve several problems and got several answers to

  • 0

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 you can help me. :/

I’ve been trying to zoom in and out of a GridView, but got over to an other solution, since I do only need two states: an overview and a detailed view. Therefor I’ve made two Gridviews. The first one is the one where the images inside both gridviews are shrunk and displayed without scrolling. The other one is the one where the images are displayed in their original size. You can scroll horizontally and vertically inside that one.

My problem is the switching between those two gridviews. I’ve tried to “set the visibility” of both to either “gone” or “visible” if i clicked on one of them.

Here’s my code:

Starter:

package test.scroll;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.view.View;
import android.view.View.OnClickListener;

public class TestScrollActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    final GridView grd_overview = (GridView)this.findViewById(R.id.grd_overview);
    grd_overview.setAdapter(new OverviewImageAdapter(this));
    final GridView grd_detailed = (GridView)this.findViewById(R.id.grd_detailed);
    grd_detailed.setVisibility(2);
    grd_detailed.setAdapter(new DetailedImageAdapter(this));

    grd_overview.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            grd_overview.setVisibility(2);
            grd_detailed.setVisibility(0);
        }
    });

    grd_detailed.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            grd_detailed.setVisibility(2);
            grd_overview.setVisibility(0);
        }
    });
    }
}

OverviewAdapter:

package test.scroll;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class OverviewImageAdapter extends BaseAdapter {  
     private Context mContext;

        public OverviewImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return mThumbIds.length;
        }

        public Object getItem(int position) {
            return null;
        }

        public long getItemId(int position) {
            return 0;
        }

        // create a new ImageView for each item referenced by the Adapter
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {  // if it's not recycled, initialize some attributes
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.LayoutParams(82, 82));
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            } else {
                imageView = (ImageView) convertView;
            }

            imageView.setImageResource(mThumbIds[position]);
            return imageView;
        }

        // references to our images
        private Integer[] mThumbIds = {
                R.drawable.memory_1, R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,
                R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,
                R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,
                R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,
                R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,
                R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1,R.drawable.memory_1
        };

    }  

DetailedAdapter:

package test.scroll;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class DetailedImageAdapter extends BaseAdapter {  
     private Context mContext;

        public DetailedImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return mThumbIds.length;
        }

        public Object getItem(int position) {
            return null;
        }

        public long getItemId(int position) {
            return 0;
        }

        // create a new ImageView for each item referenced by the Adapter
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {  // if it's not recycled, initialize some attributes
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.LayoutParams(82, 82));
            } else {
                imageView = (ImageView) convertView;
            }

            imageView.setImageResource(mThumbIds[position]);
            return imageView;
        }

        // references to our images
        private Integer[] mThumbIds = {
                R.drawable.memory_2, R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,
                R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,
                R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,
                R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,
                R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,
                R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2,R.drawable.memory_2
        };

    }  

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/app_layout" 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        >

        <!-- PLAYGROUND -->
        <test.scroll.TwoDScrollView 
                android:id="@+id/scene_scroller" 
                android:drawingCacheQuality="low" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                >
                <LinearLayout
                        android:id="@+id/grds"
                        android:drawingCacheQuality="low"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        >
                        <GridView
                                android:id="@+id/grd_overview"
                                android:drawingCacheQuality="low"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                />
                        <GridView
                                android:id="@+id/grd_detailed"
                                android:drawingCacheQuality="low"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                />

                </LinearLayout>
        </test.scroll.TwoDScrollView>

        <!-- ATTRIBUTES -->
        <Button
                android:id="@+id/btn_cancel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/scene_scroller"
                android:text="cancel"
                />    

</RelativeLayout>

Do you have any suggestions for me on how to switch between those two gridview? Let me know 🙂

Basti

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:16:45+00:00Added an answer on May 21, 2026 at 3:16 pm

    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 )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.