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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:57:28+00:00 2026-06-13T06:57:28+00:00

I am trying to make a ImageButton that opens a Gallery with images. I

  • 0

I am trying to make a ImageButton that opens a Gallery with images. I am trying to make it simple for now – just when I click the image to open the gallery with a couple of pictures. But I am not sure how to do it. I have searched on the Internet and saw that others are having the XML code that invokes one Java method – OnClick. I have the XML here:

<ImageButton
   android:id="@+id/imageView5"
   android:layout_width="@dimen/overview_schedule_image_width"
   android:layout_height="match_parent"
   android:layout_marginTop="10dp"
   android:src="@drawable/red"
   android:onClick="buttonClick" />

There is more code in the XML, but I think that’s the one that is necessary. So far it works good. But now I am not sure where to place that “buttonClick” method and what it should contain. I have made this class:

package org.imageGallery;

import org.imageGallery.actionbarcompat.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Gallery;

public class ButtonClickActivity extends ActionBarActivity implements OnItemSelectedListener, OnClickListener{

@Override
public void onClick(View v) {

}

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
        long arg3) {

}

@Override
public void onNothingSelected(AdapterView<?> arg0) {

}
}

I guess the “buttonClick” method should be placed here and it should take the images. But how do I return them to the XML and how can I display them in the gallery ? I am still very new to Android, but hopefully I will manage to do it.

EDIT:

Here is a great tutorial that helped me a lot.

  • 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-13T06:57:29+00:00Added an answer on June 13, 2026 at 6:57 am

    First you have to make a class that extends activity like this:

     public class Main extends Activity{}
    

    1. then override a method called OnCreate() which launches when the activity launches.

    1. override in onCreate block method called setContentView(R.layout.yourLayout) so the activity displays the xml file.

    2. then get a reference to the button so you can listen to it this way: Button myButton = (Button) findViewById(R.id.button1);

    if you implemented OnClickListener in your class then in the implemented method:

    @Override
    public void onClick(View v) {
    if(v.getItemId() == R.id.button1){
    //do what you want here:
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media/16"))) //As deeper answered to open the gallery
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to just make an activity that simply loads a random image when
I am trying to make a click event with Javascript on this image button
Im trying to make it so that on a press of a image button
I'm trying make an entity with doctrine that has three associations with other entities
I am fairly new to iOS development and trying make a simple app which
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I'm trying to make a simple picture thumbnail application. I've searched the web and
I am trying make such application which speak automatically when the image loaded it
I'm trying make a simple control, with a some path in it. And binding

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.