On Wed, Aug 29, 2012 at 10:03 PM, Justin Anderson <[email protected]>wrote:

> Please post the relevant code where you are setting up and handling your
> item click.
>

All right, following is my onItemClick event of gridview, on which I am
adding the clicked image in the gallery situated on the bottom of the
screen, and removing that selected image from the gridview.. All is working
well, when I click any image from the grid.
But, in the case, when I click empty position after the last one, (*when I
do have more than 8 images in my grid*), the returned position is somewhat
8 less than the total items in my grid, as well as item of the returned
position is dropped into the gallery and removed from the grid.


*Grid OnItemClick event*
*
*
private OnItemClickListener mOnItemClickListener = new
OnItemClickListener() {

public void onItemClick(AdapterView<?> adapterView, View v, int position,
long id) {

if(adapterView == draggableGrid)
{


GridPhoto mGridPhoto = gridItemAdapter.getItem(position);
onGridPhotoDropped(mGridPhoto, gallaryItemAdapter.getCount());
Log.d("grid","clicked item position="+position);
findViewById(R.id.dragtxt).setVisibility(View.INVISIBLE);
gridItemAdapter.notifyDataSetChanged();

}

}
};


*GridView Adapter*
*
*
package com.views.viewAdapters;

import java.io.File;
import java.util.ArrayList;

import android.content.Context;
import android.content.res.TypedArray;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.Classes.GridPhoto;
import com.Slideshow.AG;
import com.Slideshow.R;

public class GridItemAdapter extends BaseAdapter {

private Context context;

int imageBackground;
public GridItemAdapter(Context context, ArrayList<GridPhoto>
mGridPhoto_list){

this.context = context;
TypedArray ta = context.obtainStyledAttributes(R.styleable.Gallery1);
imageBackground =
ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
ta.recycle();
}



public int getCount() {
int count = AG.loadedProject.getProject_gridPhoto_list().size();
if(count>3000)
count=3000;
return count;
}
public GridPhoto getItem(int arg0) {
return AG.loadedProject.getProject_gridPhoto_list().get(arg0);
}


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

@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
}

public View getView(int position, View convertView, ViewGroup arg2) {

if(convertView == null){
convertView =
(RelativeLayout)RelativeLayout.inflate(context,R.layout.grid_item, null);
}

ImageView iv = (ImageView) convertView.findViewById(R.id.imgPhoto_gridItem);

GridPhoto gp = AG.loadedProject.getProject_gridPhoto_list().get(position);
String t_path = gp.getThumbnailImagePath();


if(t_path != null && new File(t_path).exists())
{
Uri imgUri = Uri.parse(gp.getThumbnailImagePath());
if(gp.getThumbnailImageBitmap() == null)
iv.setImageURI(imgUri);
//iv.setImageResource(R.drawable.icon_processing_gif);
else
iv.setImageBitmap(gp.getThumbnailImageBitmap());
}
else if(t_path != null)
{
if(t_path.equals("_#processing"))
iv.setImageResource(R.drawable.icon_processing_gif);
else
iv.setImageResource(R.drawable.no_image_found_icon);
}
else
iv.setImageResource(R.drawable.no_image_found_icon);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setBackgroundResource(imageBackground);


return convertView;
}


}


Now, please suggest, whats wrong I am doing?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to