You can set title
and url
as tag to each button
buttons[i].setTag(1, title);
buttons[i].setTag(2, url);
and rerieve the tag inside onClick
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(HouseDetail.this, HouseDetailPdf.class);
intent.putExtra("title", v.getTag(1));
intent.putExtra("url", v.getTag(2));
startActivity(intent);
}
Or else you can do something like this.Store the index
as the tag so that you can get the index
when the button
is clicked.
buttons[i].setTag(i);
Get the index
which is stored as tag
.
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int position = Integer.parseInt(v.getTag().toString());
Intent intent = new Intent(HouseDetail.this, HouseDetailPdf.class);
intent.putExtra("title", titles[position]);
intent.putExtra("url", urlOfButtons[position]);
startActivity(intent);
}