I have a gridView and I\'d like to launch a different intent depending on the position of the item clicked.
I\'ve instantiated the following onClick listener which
from the android documentation for GridView:
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView> parent, View v, int position, long id) {
Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
edit: It looks like the addNewImageToScreen() is where you are adding the ImageCells, so assuming that you can generate the intent in that scope..
Intent intent = new Intent(this, Activity1.class); // or whatever you want to run
ImageCell newView = ...
newView.setTag( intent );
then in your onItemClick: public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show(); Intent intent = (Intent) v.getTag(); // now you can startActivity with your intent.. }