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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:16:26+00:00 2026-06-10T21:16:26+00:00

I was trying an gallery app and i found an eample @ http://raivoratsep.com/114/android-gallery-tutorial-working-example/ and

  • 0

I was trying an gallery app and i found an eample @ http://raivoratsep.com/114/android-gallery-tutorial-working-example/ and i builds smoothly but in emulator it shows a blank white screen…
here i post my code..
public class GallaryActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallary);
    Gallery g = (Gallery) findViewById(R.id.gallery1);
    final Gallary_adapter ga = new Gallary_adapter(this);
    g.setAdapter(ga);

    g.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Toast.makeText(GallaryActivity.this, "" + position, Toast.LENGTH_SHORT).show();
/*            Intent intent= new Intent("hello");
            long id1 = ga.getItemId(position);

          intent.putExtra("key", id1);

            sendBroadcast(intent);    */
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_gallary, menu);
    return true;
}
}

and Gallary_adapter class is like this..

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

    private Integer[] mImageIds = {
            R.drawable.sample_1,
            R.drawable.sample_2,
            R.drawable.sample_3,
            R.drawable.sample_4,
            R.drawable.sample_5,
            R.drawable.sample_6,
            R.drawable.sample_7
    };
Gallary_adapter(Context c){
    mContext=c;
    TypedArray a = c.obtainStyledAttributes(R.styleable.Gallery1);
    mGalleryItemBackground = a.getResourceId(
            R.styleable.Gallery1_android_galleryItemBackground, 0);
    a.recycle();
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ImageView i = new ImageView(mContext);

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

    return i;
}



}

and this helpful link i found to remove all errors with ‘R.stylable’ https://groups.google.com/forum/?fromgroups=#!topic/android-beginners/AJfST9YGADM

and here is the xml layout file..

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:id="@+id/lay">

<Gallery
    android:id="@+id/gallery1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="164dp" />

please help me out..
thank u 🙂

  • 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-06-10T21:16:28+00:00Added an answer on June 10, 2026 at 9:16 pm

    Your getCount returns Zero in your Gallary_adapter class,

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return 0;
    }
    

    it must return,

    mImageIds length like this,

     @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return mImageIds.length;
        }
    

    GetCount is responsible for calculating the number of items in your Gallery.

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

Sidebar

Related Questions

I am trying to open an image / picture in the Gallery built-in app
Im a newbie RoR kid, and I'm trying to make a web gallery app
I am trying to Build a gallery in Android ( Not exactly what is
I'm trying to make a button in my App open the built in gallery.
I'm trying to make a small app (an image gallery from images from the
So what I'm trying to do is to write a simple gallery app -
I am trying to play with making my app look better and I found
Im trying to create my own url scheme so my android app can get
i'm trying to make a custom Gallery in my app. I created a class
Im trying to create a gallery for my website, so i use max-height/width to

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.