I have an activity which consists of a GridView with multiple (different) images. When the user clicks on one image, a customized dialog box shows up in which an enlarged version of the image appears as well as some text below.
What I want accomplished: the image shown in the dialog box must correspond to the chosen image in the GridView. I thought that I could change the image resource in the onItemClick method, but the application crashes instead (only when I use the setImageResource command).
Here is the code:
public class Releases extends OptionsActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.releases);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ReleasesImgAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
//Toast.makeText(Releases.this, "" + position, Toast.LENGTH_SHORT).show();
if (position == 0)
{
CustomizeDialog cdWCE = new CustomizeDialog(Releases.this, R.layout.releases_popup);
ImageView wce = (ImageView)findViewById(R.id.rlsImg);
wce.setImageResource(R.drawable.image2);
cdWCE.show();
}
}
});
}
}
releases.xml simply consists of a GridView.
I can’t debug the program because my Eclipse debugging haven’t been working for a while now.
Try finding the
ImageViewin the actual dialog where you set the layout (e.g.