This is a gridview that get image from json. and it works fine. I want to click image in this gridview to show full image and can slide it. I find the solution of this probl
its same as you need. just click event of grid view and get image in next screen using view pager.
Click event of grid view images:
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new ImageAdapter());
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
HashMap<String, Object> selected = (HashMap<String, Object>)
gridView.getItemAtPosition(position);
}
});
See this class you can find
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new ImageAdapter());
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
startImageGalleryActivity(position);
}
});
Here you will get same output what you wants.
You can also download complete source code here
is this url of your image?
-> map.put("photo", (String) c.getString("photo"));//on your main activity
try using onclick on myView
myView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HashMap<String, Object> result = new HashMap<String, Object>();
result = MyArr.get(position);
Intent intent = new Intent(context, youractivitytarget.class);
intent.putExtra("photo", (String)result.get(MainActivity.PHOTO));
context.startActivity(intent);
}
});
then use url to download your clicked photo again
First of all you have to implement ImageAdapter class' method getItem(int position) to return the item at "position" in MyArr. Next, in click listener, you can do something like
HashMap<String, Object> selected = (HashMap<String, Object>) gridView.getItemAtPosition(position);
With selected you have your bitmap.