I am fetching image from remote server using a LazyList in a grid view . I am trying to modify my gridview to a clickable gridview which view the downloaded image in fullscreen with specific position. Images are being cached on SD card and in memory with LazyList.I wanted to get the image by position of url
Here is my code but i still don't get it to work .Any helps would be greatly appreciated!
this is my OnItemClicklistener in grid view
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
// Sending image position to FullScreenActivity
Intent i = new Intent(getActivity(), FullImageActivity.class);
// passing array index
i.putExtra("string", pathA);
i.putExtra("position", position);
startActivity(i);
}
here is What i call to get specific image to view in fullscreen activity.I don't really understand how to call image with position using the same adapter
// get intent data
Intent i = getIntent();
// Selected image position
int position = i.getExtras().getInt("id");
String[] d = i.getStringArrayExtra("string");
LazyAdapter imageAdapter = new LazyAdapter(this, d);
ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
imageView.setImageResource(imageAdapter.d[position]);
Here is part of my adapter that i used public class LazyAdapter extends BaseAdapter {
private Activity activity;
public String[] data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, String[] d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
ImageView image=(ImageView)vi.findViewById(R.id.image);
imageLoader.DisplayImage(data[position], image);
return vi;
}
}
After tons of trying i finally get it to work , hope its help others
In the fullscreenactitivty.java
// get intent data
Intent i = getIntent();
// Selected image url with position
int position = i.getExtras().getInt("position");
String[] d = i.getStringArrayExtra("string");
ImageLoader imageLoader = new ImageLoader(getApplication());
ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
imageLoader.DisplayImage(d[position], imageView);