jacobmoncur / QuiltViewLibrary

Android Quilt View Library
554 stars 191 forks source link

Click Event !! #9

Open mohamad-amin opened 11 years ago

mohamad-amin commented 11 years ago

Is it possible to answer clicks on different windows in QuiltView ? Thanks.

balazsgerlei commented 11 years ago

You could add an Onclick listener yourself when adding the child view / images to the QuiltView.

Expanding the the example:

ArrayList<ImageView> images = new ArrayList<ImageView>();
for(int i = 0; i < num; i++){
    final int index = i;
    ImageView image = new ImageView(this.getApplicationContext());
    image.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    String message = "image " + index + " clicked!";
                    Toast toast = Toast.makeText(getSherlockActivity(), message, Toast.LENGTH_SHORT);
                    toast.show();
                }
            });
    image.setScaleType(ScaleType.CENTER_CROP);
    image.setImageResource(R.drawable.bg);
    images.add(image);
}
quiltView.addPatchImages(images);