示範如何以程式方式使用 Aspose.Slides for Android via Java 來管理簡報的節——新增、存取、移除與重新命名。

新增節

建立一個從特定投影片開始的節。

static void addSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        // 指定標示此節開始的投影片。
        presentation.getSections().addSection("New Section", slide);
    } finally {
        presentation.dispose();
    }
}

存取節

從簡報中讀取節的資訊。

static void accessSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        presentation.getSections().addSection("My Section", slide);

        // 使用索引存取節。
        ISection section = presentation.getSections().get_Item(0);
        String sectionName = section.getName();
    } finally {
        presentation.dispose();
    }
}

移除節

刪除先前新增的節。

static void removeSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        ISection section = presentation.getSections().addSection("Temporary Section", slide);

        // 移除第一個節。
        presentation.getSections().removeSection(section);
    } finally {
        presentation.dispose();
    }
}

重新命名節

變更現有節的名稱。

static void renameSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        presentation.getSections().addSection("Old Name", slide);

        ISection section = presentation.getSections().get_Item(0);
        section.setName("New Name");
    } finally {
        presentation.dispose();
    }
}