SegmentedButton icon indicating copy to clipboard operation
SegmentedButton copied to clipboard

Deleting last segment error

Open bahaahany2019 opened this issue 5 years ago • 0 comments

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);
    }
    }

bahaahany2019 avatar Nov 27 '20 09:11 bahaahany2019