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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:36:27+00:00 2026-06-12T03:36:27+00:00

I am providing my code here.i have breaked an image into 9 parts and

  • 0

I am providing my code here.i have breaked an image into 9 parts and shown in grid view how to change images by clicking on them i.e.,(first clicked image should be replaced with second clicked image and vice versa)i have used bitmap array for splitting images and placed them in grid view. so how to change images in grid view by clicking two images the swapping of images should be done how can any one help me.

public class Imagepieces extends Activity {
                ArrayList<Bitmap> breakedimages,duplicate;
                GridView g;
                int i=0,temp,temp2,rpos;

                @Override

                protected void onCreate(Bundle savedInstanceState) {
                    // TODO Auto-generated method stub
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_image);
                    breakedimages = getIntent().getParcelableArrayListExtra("breaked image");
                    duplicate = new ArrayList<Bitmap>(breakedimages);
                    Collections.shuffle(duplicate);
                    g = (GridView) findViewById(R.id.gridView1);
                    g.setAdapter(new CutAdapter(this, breakedimages));
                    g.setNumColumns((int) Math.sqrt(breakedimages.size()));
                    g.setOnItemClickListener(new OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {                
                            // TODO Auto-generated method stub
                            //=================================================
                            {






                        }
                    });
                }

                class CutAdapter extends BaseAdapter {
                    int iwidth, iheight; 
                    Context context;

                    public CutAdapter(Imagepieces ipieces, ArrayList<Bitmap> breakedimages) {
                        // TODO Auto-generated constructor stub
                        iwidth = breakedimages.get(0).getWidth();
                        iheight = breakedimages.get(0).getHeight();
                        context = ipieces;
                    }

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

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

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

                    @Override
                    public View getView(int arg0, View arg1, ViewGroup arg2) {
                        // TODO Auto-generated method stub
                        ImageView i=new ImageView(context);

                        i.setLayoutParams(new GridView.LayoutParams(iwidth +5,iheight +5));
                        i.setPadding(0, 0, 0, 0);
                        i.setImageBitmap(duplicate.get(arg0));

                        return i;
                    }

                }
            }



can any one do the need for me as i have stuck here how to move the images among themselves 
  • 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-12T03:36:29+00:00Added an answer on June 12, 2026 at 3:36 am

    Another way we can implement.

    In onItemClickListener()

         i++;
         Bitmap b = null;
         if (i % 2 != 0) {
           temp = arg2;
           b = duplicate.get(temp);
         }
         if (i % 2 == 0) {
            temp2 = arg2;
            duplicate.set(temp, duplicate.get(arg2));
            duplicate.set(temp2, b);
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have posted similar question previously, but this time I am providing some code
I have packed some of my code into a function. But when I try
I have this method: public function activation_code() { //activation code sent into db $activation_code
I have created a mycustomItemsPanel in App.Resources <Application.Resources> <ItemsPanelTemplate x:Key=mycustomItemsPanel> .... Some code here
I am providing u the sample code that i have did so far. What
I have a code structure where there is base controller class providing the basic
Here is the current code in my application: String[] ids = str.split("/"); When profiling
I'm attempting to supplement the help features for my code by providing other developers
I have a weird question. After profiling my code several times with NYTProf. I
I have to write a lot of code that's going to generate Knockout JS

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.