for ( int i = 0; i < responses.size(); i++ )
{
Button btn = new Button( this );
btn.setText( guideStep.getResponse( i ).getTitle() );
btn.setOnClickListener(new OnClickListener() {
public void onClick( View v )
{
try
{
//NextStep(guideStep.getStep(), guideStep.getSession(), guideStep.getResponse( i ).getId() );
}
catch( Exception e )
{
e.printStackTrace();
}
}
});
linearLayout.addView( btn );
}
Looking at the following code. I am adding buttons dynamically to my linear layout. I need to, dynamically aswell, change the onClick event for each button. For that, I need the counter from the loop and some way to save my guideStep object, from without the loop aswell.
Is there any way to do this?
1 Answer