SegmentedButton
SegmentedButton copied to clipboard
Deleting last segment error
Hi, I create segments at runtime all working fine my problem is in deleting the last segment for example if i have 3 segments i can delete the first & second without any problems but if i tried to delete the third the app crashes below is the delete code please advice.
btnDeleteSeg.setOnClickListener(new` View.OnClickListener()
{
@Override
public void onClick (View v){
bibleSegIndex = segmentedButtonGroup.getPosition();
if (bibleSegIndex == 0) {
segmentedButtonGroup.setPosition(0, false);
} else {
segmentedButtonGroup.setPosition(0, true);
}
segmentedButtonGroup.getButton(bibleSegIndex).setVisibility(View.GONE);
segmentedButtonGroup.getButtons().remove(bibleSegIndex);
}
}