I cant gte the gallery UI object to work in android.
I followed this

and the imageAdapter is a class beneath the HeloGallery class?
I just get a bunch of errors
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

package com.example8;

import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Gallery;
import android.widget.Toast;
import android.view.View;

public class HelloGalleryActivity extends Activity {
    /** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) {

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

	    gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
	        public void onItemClick(AdapterView parent, View v, int position, long id) {
	            Toast.makeText(HelloGalleryActivity.this, "" + position, Toast.LENGTH_SHORT).show();

Open in new window

package com.example8;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
	   int mGalleryItemBackground;
	    private Context mContext;

	    private Integer[] mImageIds = {

	    public ImageAdapter(Context c) {
	        mContext = c;
	        TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGallery);
	        mGalleryItemBackground = attr.getResourceId(
	                R.styleable.HelloGallery_android_galleryItemBackground, 0);

	    public int getCount() {
	        return mImageIds.length;

	    public Object getItem(int position) {
	        return position;

	    public long getItemId(int position) {
	        return position;

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

	        imageView.setLayoutParams(new Gallery.LayoutParams(150, 100));

	        return imageView;


[embed=file 563514]

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SanthanaTechnical LeadCommented:
Hi jagguy,

First mention what kind of errors you are getting in your application.  
Simply if you say "I just get a bunch of errors" how we will help you????

I have copy pased the code from the link you mentioned.. It is working perfectly to me....
jagguyAuthor Commented:
I did fix this when I redid the project.
There is known problems with this example under android 2.2 as I found on internet.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.