I am trying to show a dialog on the click of my table row.My table rows are dynamically generated, having 3 columns.1 ImageView and 2 TextViews.
My table rows are generated by this loop
for (i = 0; i < name.length; i++)
{
tr = new TableRow(this);
ImageView iv = new ImageView(this);
tr.setClickable(true);
tr.setOnClickListener(this);
try {
url = new URL(image_url[i]);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream content = null;
try {
content = (InputStream)url.getContent();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Drawable d = Drawable.createFromStream(content , "src");
iv.setImageDrawable(d);
tr.addView(iv,new LayoutParams(150,150));
tv2 = new TextView(this);
tv3 = new TextView(this);
tv2.setText(name[i]);
tv3.setText(location[i]);
tv2.setPadding(10, 0, 0, 0);
tv3.setPadding(10, 0, 0, 0);
tr.setPadding(0, 1, 0, 1);
tr.addView(tv2); // add TextView to row.
tr.addView(tv3); // add TextView to row.
tl.addView(tr);
}
I have tried so many things to make the rows clickable,but nothing seems to work. The onclicklistner method calls the onClick() method that I have defined in my code but it is never called.Please let me know what is the way through which I can call a show dialog method on the click of a particular row.Thanks