Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何访问midlet类中的多选项组作为选择_Java_Java Me - Fatal编程技术网

Java 如何访问midlet类中的多选项组作为选择

Java 如何访问midlet类中的多选项组作为选择,java,java-me,Java,Java Me,我创建了一个扩展MIDLet的类。我创建了另一个类,不止一个choiceGroup、textField等等。我只想一次使用choiceGroup或textField。。请帮帮我。当我在item1上选择时,屏幕上将只显示choiceGroup1和textField package tesdt; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class testMidlet extends

我创建了一个扩展MIDLet的类。我创建了另一个类,不止一个choiceGroup、textField等等。我只想一次使用choiceGroup或textField。。请帮帮我。当我在item1上选择时,屏幕上将只显示choiceGroup1和textField

package tesdt;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class testMidlet extends MIDlet implements CommandListener 
{
    Display display;
    Form form;
    Command cmdNext;
    ChoiceGroup gr4;
    public testMidlet()
    {
        display=Display.getDisplay(this);
        form =new Form("Hello World");
        cmdNext=new Command("Next", Command.SCREEN,1);
        form.addCommand(cmdNext);
        form.setCommandListener(this);
        gr4=new ChoiceGroup("Select",ChoiceGroup.EXCLUSIVE);
        gr4.append("item1", null);
        gr4.append("item2", null);
        gr4.append("item3", null);
        form.append(gr4);
    }
    public void startApp() 
    {
        display.setCurrent(form);
    }
    public void pauseApp() {
    }
    public void destroyApp(boolean unconditional) 
    {
    }
    public void commandAction(Command c, Displayable d) throws UnsupportedOperationException
    {
        if(c==cmdNext || gr4.getSelectedIndex()==1)
        {
            GUITest guitest=new GUITest();
            display.setCurrent(guitest);
        }
    }
}

package tesdt;
import javax.microedition.lcdui.*;
public class GUITest extends Form
{
    TextField tf1,tf2,tf3;
    ChoiceGroup gr1,gr2,gr3;
    String[] gr1Item={"item1","item2","item3","item4"};
    String[] gr2Item={"Name","Age","Sex","DOB"};
    String[] gr3Item={"Delhi","Mumbai","Patna","Bangalore"};
    Command com; 
//    testMidlet testMidlet; 
    public GUITest()
    {
        super("hi");
        com=new Command("Next on", Command.SCREEN,1);
    }
    public Command getCom()
    {
       return com;
    }
    public ChoiceGroup getGr1()
    {
       return gr1;
    }
    public void setGr1()
    {
        gr1=new ChoiceGroup("Item",ChoiceGroup.EXCLUSIVE,gr1Item,null);
        append(gr1);
    }
    public ChoiceGroup getGr2()
    {
        return gr2;
    }
    public void setGr2()
    {
        gr2=new ChoiceGroup("Record",List.EXCLUSIVE,gr2Item,null);
        append(gr2);
    }
    public ChoiceGroup getGr3()
    {
        return gr3;
    }
    public void setGr3()
    {
        gr3=new ChoiceGroup("Item",ChoiceGroup.EXCLUSIVE,gr3Item,null);
        append(gr3);
    }
    public TextField getTf1()
    {
        return tf1;
    }
    public void setTf1()
    {
        tf1=new TextField("Record","Enter Item",20,TextField.ANY);
        append(tf1);
    }
    public TextField getTf2()
    {
        return tf2;
    }
    public void setTf2()
    {
        tf2=new TextField("Item","Enter Record",20,TextField.ANY);
        append(tf2);
    }
    public TextField getTf3()
    {
        return tf3;
    }
    public void setTf3()
    {
        tf3=new TextField("Item","Enter City",20,TextField.ANY);     
        append(tf3);

    }
}

}

添加您的类别代码…请尽快提供帮助