Skip to content

Deleting last segment error #45

Description

@bahaahany2019

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions