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

  • Home
  • SEARCH
  • 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 7061997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:32:30+00:00 2026-05-28T04:32:30+00:00

i have a grid view which contain images when click on one image it

  • 0

i have a grid view which contain images when click on one image it should open in a another page.ie i need to pass the image from one activity to another where i want to get the pixels of the image.i have the code to get the pixels.what i need is that i have to show the image in anther activity so that to get the pixels.how to pass the selected image from one activity to another in android .i have tried some of the solution from stack overflow but it did not worked

//GridviewActivity.java

package gr.ed.vi;

          import android.app.Activity;
              import android.content.Context;
                import android.content.Intent;
           import android.os.Bundle;
           import android.view.View;
           import android.view.ViewGroup;
           import android.widget.AdapterView;
            import android.widget.BaseAdapter;
              import android.widget.GridView;
             import android.widget.ImageView;
                   import android.widget.Toast;
            import android.widget.AdapterView.OnItemClickListener;

      public class GridviewActivity extends Activity
    {    
    //---the images to display---
     Integer[] imageIDs = {
        R.drawable.ic_launcher,
        R.drawable.ic_launcher,
        R.drawable.ic_launcher,
        R.drawable.ic_launcher,
        R.drawable.ic_launcher,
        R.drawable.ic_launcher,
        R.drawable.ic_launcher                    
};

@Override    
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    GridView gridView = (GridView) findViewById(R.id.gridview);
    gridView.setAdapter(new ImageAdapter(this));

    gridView.setOnItemClickListener(new OnItemClickListener() 
    {
        public void onItemClick(AdapterView parent, 
        View v, int position, long id) 
        {                
           /* Toast.makeText(getBaseContext(), 
                    "pic" + (position + 1) + " selected", 
                    Toast.LENGTH_SHORT).show();*/
            switch(position){
           case 0:

           break;
           case 1:
           //call second class
              Intent intent = new Intent(GridviewActivity.this, sm.class);

         //  intent.putExtra("photo",imageIDs);
           //  Log.d(TAG, "jpegCallback1" +data);
            startActivity(intent); 

             // intent.putExtra("img", imageIDs);
             //startActivity(intent);

           break;
           case 2:
           //call third class
               Intent k1=new Intent(GridviewActivity.this,sm.class);
               startActivity(k1);
           break;

           default:
           break;
               }
        }
    });        
   }

   public class ImageAdapter extends BaseAdapter 
    {
    private Context context;

    public ImageAdapter(Context c) 
    {
        context = c;
    }

    //---returns the number of images---
    public int getCount() {
        return imageIDs.length;
    }

    //---returns the ID of an item--- 
    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    //---returns an ImageView view---
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(context);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(5, 5, 5, 5);
        } else {
            imageView = (ImageView) convertView;
        }
        imageView.setImageResource(imageIDs[position]);
        return imageView;
       }
   }    
  }

sm.java

package gr.ed.vi;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.AvoidXfermode.Mode;
import android.graphics.Bitmap.Config;
import android.graphics.BlurMaskFilter.Blur;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class sm extends Activity {
/** Called when the activity is first created. */
Bitmap overlay;      
Paint pTouch;
int X = -100;
int Y = -100;
Canvas c2;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    byte[] photo = extras.getByteArray("photo");
    Bitmap mBitmap  = BitmapFactory.decodeByteArray (photo, 0, photo.length);
    Bitmap mBitmapover  = BitmapFactory.decodeByteArray (photo, 0, photo.length);

             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,              
     WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
   // Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),         
    R.drawable.android);
   // Bitmap mBitmapover = BitmapFactory.decodeResource(getResources(), R.drawable.ss);
    overlay =   
    BitmapFactory.decodeResource                 
   (getResources(),R.drawable.ss).copy(Config.ARGB_8888, true);  
    c2 = new Canvas(overlay);

    pTouch = new Paint(Paint.ANTI_ALIAS_FLAG);         
  //  pTouch.setXfermode(new PorterDuffXfermode(Mode.TARGET); 
    pTouch.setColor(Color.TRANSPARENT);
    pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));
    setContentView(new BitMapView(this, mBitmap,mBitmapover));
}

class BitMapView extends View {
    Bitmap mBitmap = null;
    Bitmap mBitmapover = null;

    public BitMapView(Context context, Bitmap bm, Bitmap bmover) {
    super(context);
    mBitmap = bm;
    mBitmapover = bmover;
    }
     @Override
     public boolean onTouchEvent(MotionEvent ev) {

         switch (ev.getAction()) {

             case MotionEvent.ACTION_DOWN: {

                 X = (int) ev.getX();
                 Y = (int) ev.getY();
                 invalidate();

                 break;
             }

             case MotionEvent.ACTION_MOVE: {

                     X = (int) ev.getX();
                     Y = (int) ev.getY();
                     invalidate();
                     break;

             }           

             case MotionEvent.ACTION_UP:

                 break;

         }
         return true;
     }


    @Override
    protected void onDraw(Canvas canvas) {
    // called when view is drawn
    Paint paint = new Paint();
    paint.setFilterBitmap(true);
    // The image will be scaled so it will fill the width, and the
    // height will preserve the image’s aspect ration
/*  double aspectRatio = ((double) mBitmap.getWidth()) / mBitmap.getHeight();
    Rect dest = new Rect(0, 0, this.getWidth(),(int) (this.getHeight() / aspectRatio));
    double aspectRatio2 = ((double) mBitmapover.getWidth()) / mBitmapover.getHeight();
    Rect dest2 = new Rect(0, 0, this.getWidth(),(int) (this.getHeight() / aspectRatio2));
    canvas.drawBitmap(mBitmap, null, dest, paint);
    canvas.drawBitmap(mBitmapover, null, dest2, paint);                    */

    //draw background
    canvas.drawBitmap(mBitmap, 0, 0, null);
    //copy the default overlay into temporary overlay and punch a hole in it                          
    c2.drawBitmap(mBitmapover, 0, 0, null); //exclude this line to show all as you draw
    c2.drawCircle(X, Y, 80, pTouch);
    //draw the overlay over the background  
    canvas.drawBitmap(overlay, 0, 0, null);
    }
}
  • 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-28T04:32:31+00:00Added an answer on May 28, 2026 at 4:32 am

    *when you click a image get the paht/uri of that image and create intent and put the value with intent and get it in another activity and show it.

    ex:

    gridview.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                  int i=R.drawable.ic_launcher;
    
                 Intent intent = new Intent(SamaaActivity.this,kl.class); 
                intent.putExtra("intVariableName", i);
                startActivity(intent);
        }
    });
    

    and get this on other activity

    Intent mIntent = getIntent();
        int intValue = mIntent.getIntExtra("intVariableName", 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a grid-view, which contains an asp image-button for deleting row, i want
I have an image in a view which contains a 9x9 grid. I want
I have a grid view which is used to show the Product details. Another
I have a GridView in which each row has a custom view. The grid
I have a grid view which contains some sequence numbers. Each column needs to
I have a parent grid view (UserTransactionGridView) which i'm binding with the output from
I have a grid in which, I load data from database. I need to
I have grid view which contains five radio buttons per row. Out of these
I am trapped in one problem. I have a page which contains some taxboxes.
I have a grid view which contains 10 rows and 3 columns.. Now i

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.