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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:06:53+00:00 2026-06-12T16:06:53+00:00

I am currently developing one game! In that there is a frame layout in

  • 0

I am currently developing one game! In that there is a frame layout in that there is one HorizontalView and One in VerticalView and AbsoluteLayout and in Absolutelayout is at Top Right in that there is a ImageView

Now In HorizontalView and VerticalView there is a list of dresses of images. when i click on that image the of dress will be added to the Abosolute layout.. And in imageView there is a one cartoon.. now i can drag and drop that dress into this cartoon

for that XML code is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pink_bg" >



<ListView android:id="@+id/vlistview"
    android:layout_alignParentTop="true"
    android:layout_width="60dp"
    android:layout_marginBottom="60dp"
    android:layout_height="wrap_content"
    android:scrollingCache="false"/>

<com.devsmart.android.ui.HorizontalListView
    android:id="@+id/hlistview"
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    />

<AbsoluteLayout
    android:id="@+id/frameLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="60dp"
    android:layout_marginLeft="60dp"
    android:padding="10dp" >

         <ImageView
             android:id="@+id/imgKitty"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:src="@drawable/hk1" />

</AbsoluteLayout>

Now the code is

  public class MainActivityAbs extends Activity implements OnClickListener, OnTouchListener {
int images1[], images2[];
static int imgKittyNo = 0;
static int kittyStatus = 0;
int[] kitties;
ImageView imgKitty;
ImageView mKittyDress;
private AbsoluteLayout mKittyBGLayer;
ArrayList<ImageView> mArrayList = new ArrayList<ImageView>();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    kitties = new int[] { R.drawable.hk1, R.drawable.hk2, R.drawable.hk3, R.drawable.hk4, R.drawable.hk5 };

    images1 = new int[] { R.drawable.hk_a1, R.drawable.hk_a2, R.drawable.hk_a3, R.drawable.hk_a4, R.drawable.hk_a5, R.drawable.hk_a6,
            R.drawable.hk_a7, R.drawable.hk_a8, R.drawable.hk_dress, R.drawable.hk_dress, R.drawable.hk_dress2, R.drawable.hk_dress3,
            R.drawable.hk_dress4, R.drawable.hk_dress5, R.drawable.hk_dress6, R.drawable.hk_dress7, R.drawable.hk_dress8, R.drawable.hk_dress9,
            R.drawable.hk_dress10, R.drawable.hk_dress11, R.drawable.hk_dress12, R.drawable.hk_dress13, R.drawable.hk_dress14,
            R.drawable.hk_dress15, R.drawable.hk_dress16, R.drawable.hk_dress17, R.drawable.hk_dress18, R.drawable.hk_dress19,
            R.drawable.hk_dress20, R.drawable.hk_dress21 };

    images2 = new int[] { R.drawable.hk_flo, R.drawable.hk_flo2, R.drawable.hk_glasses, R.drawable.hk_glasses2, R.drawable.hk_glasses3,
            R.drawable.hk_hair1, R.drawable.hk_hair2, R.drawable.hk_hair3, R.drawable.hk_hair4, R.drawable.hk_hair5, R.drawable.hk_hat1,
            R.drawable.hk_hat2, R.drawable.hk_hat3, R.drawable.hk_hat4, R.drawable.hk_hat5, R.drawable.hk_hat6, R.drawable.hk_ribon1,
            R.drawable.hk_ribon2, R.drawable.hk_ribon3, R.drawable.hk_ribon4, R.drawable.hk_ribon5, R.drawable.hk_ribon6, R.drawable.hk_ribon7,
            R.drawable.hk_ribon8, R.drawable.hk_ribon9, R.drawable.hk_ribon10, R.drawable.hk_ring, R.drawable.hk_glasses, R.drawable.hk_glasses2,
            R.drawable.hk_glasses3 };

    ListView vListView = (ListView) findViewById(R.id.vlistview);
    vListView.setAdapter(new VAdapter(this));

    HorizontalListView hListView = (HorizontalListView) findViewById(R.id.hlistview);
    hListView.setAdapter(new HAdapter(this));
    imgKitty = (ImageView) findViewById(R.id.imgKitty);
    // imgKitty.setOnClickListener(this);
    mKittyBGLayer = (AbsoluteLayout) findViewById(R.id.frameLayout);
    setupViews(kitties[0]);


    vListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            setupViews(images2[arg2]);
        }

    });

    hListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            setupViews(images1[arg2]);
        }

    });

    /*imgKitty.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            System.out.println("ImgKitty is called");
        }
    });*/
    mKittyBGLayer.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            for (ImageView img1 : mArrayList) {
                if (kittyStatus == img1.getId()) {
                    mKittyDress = img1;
                    break;
                }
            }
            if(mKittyDress!=null) {
            LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, (int) event.getX() - mKittyDress.getWidth()
                    / 2, (int) event.getY() - mKittyDress.getHeight() / 2);
            mKittyDress.setLayoutParams(lp);
            }
            return true;
        }
    });

    final ImageView imgClearAll = (ImageView)findViewById(R.id.imgClearAll);
    imgClearAll.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if(mKittyBGLayer!=null && mArrayList!=null)
            {
                mKittyBGLayer.removeAllViews();
                mKittyBGLayer.addView(imgKitty);
                mArrayList.clear();
            }

        }
    });

}

@Override
public boolean onTouch(View v, MotionEvent event) {
    boolean isKitty = false;
    for (int i = 0; i < kitties.length; i++) {
        if (v.getId() == kitties[i]) {
            isKitty =true;
        }
    }
    if(!isKitty)
        kittyStatus = v.getId();
    return false;
}

private void setupViews(int args) {

    if (args == R.drawable.hk1 || args == R.drawable.hk2 || args == R.drawable.hk3 || args == R.drawable.hk4 || args == R.drawable.hk5
            || args == R.drawable.hk6) {
        imgKitty.setImageResource(args);
    } else {

        mKittyDress = new ImageView(this);
        mKittyDress.setImageResource(args);
        mKittyDress.setId(imgKittyNo++);
        mKittyDress.setOnTouchListener(MainActivityAbs.this);
        mArrayList.add(mKittyDress);
        mKittyBGLayer.addView(mKittyDress);
    }

}


private class HAdapter extends BaseAdapter {

    private Context context;
    LayoutInflater inflater;

    public HAdapter(Context context) {
        // TODO Auto-generated constructor stub
        this.context = context;
        inflater = LayoutInflater.from(context);

    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        HViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.listinflate, null);
            holder = new HViewHolder();
            convertView.setTag(holder);

        } else {
            holder = (HViewHolder) convertView.getTag();
        }
        holder.img = (ImageView) convertView.findViewById(R.id.image);
        holder.img.setImageResource(images1[position]);
        return convertView;
    }

}

class HViewHolder {
    ImageView img;
}



private class VAdapter extends BaseAdapter {

    private Context context;
    LayoutInflater inflater;

    public VAdapter(Context context) {
        // TODO Auto-generated constructor stub
        this.context = context;
        inflater = LayoutInflater.from(context);

    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.listinflate, null);
            holder = new ViewHolder();
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.img = (ImageView) convertView.findViewById(R.id.image);
        holder.img.setImageResource(images2[position]);

        return convertView;
    }

}

class ViewHolder {
    ImageView img;
}

@Override
public void onClick(View v) {
     }

Now all are done successfully with above code but when i also want that if i click on Top|Right image of boy, the image should also change, Mean there is different kind of boy they should also change when i click on that boy… I have tried so much but could not get it please any body can help me,

  • 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-12T16:06:54+00:00Added an answer on June 12, 2026 at 4:06 pm

    Check the follow posts:

    • http://codingjunkie.net/android-drag-and-drop-part1/
    • http://www.vogella.com/articles/AndroidDragAndDrop/article.html

    And also, other questions:
    Drag and drop images in android

    And finally, if you are creating an app for API Level >= 11 you should use this:
    Drag and Drop Android Page

    But first of all, remember: NEVER uses AbsoluteLayout

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

Sidebar

Related Questions

Im currently developing an API, and one thing that I decided was to have
I am currently developing a game and I'm trying to use one AnimationDrawable to
I am currently developing an application that allows the use of plugins. One of
I'm currently developing on a project which uses some TimerJobs. One of the jobs
I'm developing android application with phonegap . Currently I'm facing one problem with inputbox
I am currently developing an application , that will be published on appstore. I
I'm currently developing a facebook app that needs access to a users photos. It
In a multiplayer game I'm developing, we have a few values that are floating
I'm currently developing a web file browser using jquery and php. One of my
In the web app I am currently developing I have a form, and one

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.