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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:40:05+00:00 2026-06-13T04:40:05+00:00

My app is based on E-Commerce.I’m using gallery for images.I want to add text

  • 0

My app is based on E-Commerce.I’m using gallery for images.I want to add text and button below each image in gallery that display when i click the respected image.The text is related to product that is different for each image and button is used for to move another activity.

The code is below.I’m new in android.Any help is much appreciated.

Code:

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class GalleryView extends Activity {
Integer[] pics = {
    R.drawable.antartica1,
    R.drawable.antartica2,
    R.drawable.antartica3,
    R.drawable.antartica4,
    R.drawable.antartica5,
    R.drawable.antartica6,
    R.drawable.antartica7,
    R.drawable.antartica8,
    R.drawable.antartica9,
    R.drawable.antartica10
   };
  ImageView imageView;

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

Gallery ga = (Gallery)findViewById(R.id.Gallery01);
ga.setAdapter(new ImageAdapter(this));

imageView = (ImageView)findViewById(R.id.ImageView01);
ga.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        Toast.makeText(getBaseContext(), 
                "You have selected picture " + (arg2+1) + " of Antartica", 
                Toast.LENGTH_SHORT).show();
        imageView.setImageResource(pics[arg2]);

    }

});

}


 public class ImageAdapter extends BaseAdapter {

private Context ctx;
int imageBackground;

public ImageAdapter(Context c) {
    ctx = c;
    TypedArray ta = obtainStyledAttributes(R.styleable.Gallery1);
    imageBackground = ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
    ta.recycle();
}

public int getCount() {

    return pics.length;
}

public Object getItem(int arg0) {

    return arg0;
}

public long getItemId(int arg0) {

    return arg0;
}

public View getView(int arg0, View arg1, ViewGroup arg2) {
    ImageView iv = new ImageView(ctx);
    iv.setImageResource(pics[arg0]);
    iv.setScaleType(ImageView.ScaleType.FIT_XY);
    iv.setLayoutParams(new Gallery.LayoutParams(150,120));
    iv.setBackgroundResource(imageBackground);
    return iv;
}

}
 }
  • 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-13T04:40:06+00:00Added an answer on June 13, 2026 at 4:40 am

    modify your ImageAdapter class

    LayoutInflater mInflater;
    

    init it in ImageAdapter()

       mInflater=LayoutInflater.from(c);
    

    now Modify getView()

    public View getView(int arg0, View arg1, ViewGroup arg2) {
    View v=mInflater.inflate(R.layout.your_layout, null);
    

    ImageView iv = (ImageView)v.findViewById(R.id.imave_view);

    TextView tv=(TextView)v.findViewById(R.id.tv);
    

    tv.setTxt(//set your text);
    iv.setImageResource(pics[arg0]);
    iv.setScaleType(ImageView.ScaleType.FIT_XY);
    iv.setLayoutParams(new Gallery.LayoutParams(150,120));
    iv.setBackgroundResource(imageBackground);
    return v;
    }

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

Sidebar

Related Questions

I'm writting an ASP.NET MVC e-commerce app using NHibernate and I want the end-user
I want to develop an app based on the image in which thumbnails can
I have an app based on the CoreDataBooks example that uses an addingManagedObjectContext to
I am going to develop an app based on google map. In that locations
It is an iPad app based on SDK 3.2. I have a MainUIView, that
I have created a simple GAE app based on the default template. I want
I'm working on an app (based on Spring as DI and MVC framework) that
I have an iPhone app based on a tabBar and tableViews. I want the
In an app based on the Play! Framework (2.0, Java) I want to mock
I'm developing a web app based on videos that my client would like 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.