Senin, 30 Mei 2011

Penggunaan Choice Group pada Mobile

Item Choicegroup merupakan group dari selectable choice. choice group mempunya tiga tipe antara lain :
Eksklusif , hanya memilih satu dari pilihan yang ada.
Multiple , bisa memilih lebih dari satu pilihan.
Popup , sama seperti eksklisif hanya bisa memilih salah satu tetapi hanya satu pilihan yang ditampilkan.

Inilah contoh scriptnya :



import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class choiceGroup extends MIDlet implements CommandListener
{
    Display d;
    Form choiceForm;
    Command exitCommand = new Command("Exit", Command.EXIT,1);
    ChoiceGroup choiceExclusive, choiceMultiple, choicePopup;

    public choiceGroup()
    {
        choiceForm = new Form("Choice Group Types");
        choiceForm.addCommand(exitCommand);
        choiceForm.setCommandListener(null);
        choiceExclusive = new ChoiceGroup("Exlusive",Choice.EXCLUSIVE);
        choiceExclusive.append("Male", null);
        choiceExclusive.append("Female", null);
        choiceForm.append(choiceExclusive);

        choiceMultiple = new ChoiceGroup("Multiple", Choice.MULTIPLE);
        choiceMultiple.append("Apple", null);
        choiceMultiple.append("Orange", null);
        choiceMultiple.append("Grapes", null);
        choiceForm.append(choiceMultiple);

        choicePopup = new ChoiceGroup("Popup", Choice.POPUP);
        choicePopup.append("Asia", null);
        choicePopup.append("Europa", null);
        choicePopup.append("Americas", null);
        choiceForm.append(choicePopup);
    }
    public void startApp()
    {
        if (d == null){
            d= Display.getDisplay(this);
            d.setCurrent(choiceForm);
        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if(c == exitCommand){
         destroyApp(true);
         notifyDestroyed();//Exit
        }
    }
}

Maka tampilannya akan seperti ini :

Tidak ada komentar:

Posting Komentar