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 7193927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:16:05+00:00 2026-05-28T20:16:05+00:00

I have followed a tutorial to create a gallery with an imageview below it.

  • 0

I have followed a tutorial to create a gallery with an imageview below it. All I want to do is place the gallery on the bottom and the imageview above it, but when I switch them around in the XML it gives me a ClassCastException.

Here is the XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backrepeat"
android:orientation="vertical" >

<ImageView
    android:id="@+id/ImageView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<Gallery
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

</LinearLayout>

That is the non-working version, but placing gallery above imageview works.

From log:

01-26 22:20:13.673: E/AndroidRuntime(349): Caused by: java.lang.ClassCastException:         android.widget.ImageView
01-26 22:20:13.673: E/AndroidRuntime(349):  at     com.appinfluence.fanapp.v1.Photos.onCreate(Photos.java:36)

onCreate:

Gallery gallery = (Gallery) findViewById(R.id.gallery);
    gallery.setAdapter(new ImageAdapter(Photos.this));

    imgView = (ImageView)findViewById(R.id.ImageView01);
    imgView.setImageResource(mImageIds[0]);


    gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position, long id) {
            imgView.setImageResource(mImageIds[position]); 
        }
    });
}

Other helpful code:

public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView = new ImageView(mContext);

        imageView.setImageResource(mImageIds[position]);
        imageView.setLayoutParams(new Gallery.LayoutParams(150, 100));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setBackgroundResource(mGalleryItemBackground);

        return imageView;
    }   

http://4.bp.blogspot.com/_I2Ctfz7eew4/S_JxIfgKrfI/AAAAAAAAAzA/m1KUSIugojY/s1600/Gallery2.1.PNG

  • 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-28T20:16:06+00:00Added an answer on May 28, 2026 at 8:16 pm

    Hey NickNelson Just now i got the solution to your problem, just clean the project it will work.

    Sample screenshot

    enter image description here

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

Sidebar

Related Questions

I have followed this tutorial which allowed me to create a Silverlight DataGrid that
Hi I have followed a tutorial to create and event list in wordpress using
I have followed a tutorial to create a simple blog writing application in PHP
I have followed this tutorial to create a seek bar on a transparent background.
I have followed this tutorial to configure apn_on_rails but I am getting the following
I've followed the tutorial below, it basically just tells you to create a button
I have followed this tutorial and added iAd to my app: http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/ But the
I've followed a tutorial on how to create a HTML5 Snake game but I
I followed a tutorial to create a scrollbar template from this site: http://sachabarber.net/?p=122 But
I have followed this tutorial to create the first azure application http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_IntroToWindowsAzureLabVS2010 Because after

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.