I have got a ViewFlipper that gets populated with multiple views, that are actually the same view over and over again. Everything works fine but settings an onClickListener to a button works not like expected:
flipStack = (ViewFlipper) findViewById(R.id.clubViewFlipper);
for(int i=0; i<= clubDataSet.size()-1; i++) {
clubData = clubDataSet.get(i);
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = vi.inflate(R.layout.detail_overlay, (ViewGroup)findViewById(R.id.clubDetailScrollView), false);
Button websiteButton = (Button) view.findViewById(R.id.clubDetailWebsiteButton);
websiteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(webIntent);
}
});
flipStack.addView(view);
}
Every single websiteButton of the ViewFlipper’s views is set to the same URL now. Is there a way to change that or is my approach with a ViewFlipper wrong?
Thanks!
brejoc
You can use the tag: