Created
March 31, 2017 22:29
-
-
Save shannah/37a755ba2b949c2166fb23f143582fab to your computer and use it in GitHub Desktop.
AccordionDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codename1.tests.accordiondemo; | |
import com.codename1.components.Accordion; | |
import com.codename1.ui.Display; | |
import com.codename1.ui.Form; | |
import com.codename1.ui.Dialog; | |
import com.codename1.ui.Label; | |
import com.codename1.ui.plaf.UIManager; | |
import com.codename1.ui.util.Resources; | |
import com.codename1.io.Log; | |
import com.codename1.ui.RadioButton; | |
import com.codename1.ui.Toolbar; | |
import java.io.IOException; | |
/** | |
* This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose | |
* of building native mobile applications using Java. | |
*/ | |
public class AccordionDemo { | |
private Form current; | |
private Resources theme; | |
public void init(Object context) { | |
theme = UIManager.initFirstTheme("/theme"); | |
// Enable Toolbar on all Forms by default | |
Toolbar.setGlobalToolbar(true); | |
// Pro only feature, uncomment if you have a pro subscription | |
// Log.bindCrashProtection(true); | |
} | |
public void start() { | |
if(current != null){ | |
current.show(); | |
return; | |
} | |
Form hi = new Form("Hi World"); | |
Accordion a = new Accordion(); | |
Label l2 = new Label("Lable 2 body"); | |
a.addContent("Label 1", new Label("Label 1 body")); | |
a.addContent("Label 2", l2); | |
a.addContent("Label 3", new Label("Label 3 body")); | |
hi.add(a); | |
RadioButton rb = new RadioButton("Close"); | |
rb.addActionListener(e->{ | |
a.collapse(a.getCurrentlyExpanded()); | |
a.animateLayout(250); | |
}); | |
hi.add(rb); | |
rb = new RadioButton("Open"); | |
rb.addActionListener(e->{ | |
a.expand(l2); | |
a.animateLayout(250); | |
}); | |
hi.add(rb); | |
//hi.addComponent(new Label("Hi World")); | |
hi.show(); | |
} | |
public void stop() { | |
current = Display.getInstance().getCurrent(); | |
if(current instanceof Dialog) { | |
((Dialog)current).dispose(); | |
current = Display.getInstance().getCurrent(); | |
} | |
} | |
public void destroy() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment