Android模拟器问题

时间:2011-03-20 00:00:21

标签: java android android-emulator

每当我点击一个按钮时,它都没有做任何代码(我使用Log.d()并发现执行在setContentView(R.layout.play)之前停止:

   public void onClick(View v) {
        switch( v.getId()){
        case R.id.play:
            setContentView(R.layout.play);
            setQuestion();
        case R.id.level:
            setContentView(R.layout.level);
            if(lvl=="1") {
                lvl1.setChecked(true);
            }
            if(lvl=="2") {
                lvl2.setChecked(true);
            }
            if(lvl=="3") {
                lvl3.setChecked(true);
            }
            if(lvl=="4") {
                lvl4.setChecked(true);
            }
            if(lvl=="5") {
                lvl5.setChecked(true);
            }
            setContentView(R.layout.level);

        case R.id.setLevel:
            if(lvl1.isChecked()) {
                setLevel("1");
            }
            if(lvl2.isChecked()) {
                setLevel("2");
            }
            if(lvl3.isChecked()) {
                setLevel("3");
            }
            if(lvl4.isChecked()) {
                setLevel("4");
            }
            if(lvl5.isChecked()) {
                setLevel("5");
            }







        }
    }

当我点击关卡按钮时,它什么也没做!

logact:

03-19 00:11:57.708: ERROR/Zygote(32): setreuid() failed. errno: 2
03-19 00:12:11.897: ERROR/Zygote(32): setreuid() failed. errno: 17
03-19 00:12:15.643: ERROR/BatteryService(67): usbOnlinePath not found
03-19 00:12:15.643: ERROR/BatteryService(67): batteryVoltagePath not found
03-19 00:12:15.658: ERROR/BatteryService(67): batteryTemperaturePath not found
03-19 00:12:15.751: ERROR/SurfaceFlinger(67): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
03-19 00:12:26.218: ERROR/EventHub(67): could not get driver version for /dev/input/mouse0, Not a typewriter
03-19 00:12:26.238: ERROR/EventHub(67): could not get driver version for /dev/input/mice, Not a typewriter
03-19 00:12:26.747: ERROR/System(67): Failure starting core service
03-19 00:12:26.747: ERROR/System(67): java.lang.SecurityException
03-19 00:12:26.747: ERROR/System(67):     at android.os.BinderProxy.transact(Native Method)
03-19 00:12:26.747: ERROR/System(67):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
03-19 00:12:26.747: ERROR/System(67):     at android.os.ServiceManager.addService(ServiceManager.java:72)
03-19 00:12:26.747: ERROR/System(67):     at com.android.server.ServerThread.run(SystemServer.java:184)
03-19 00:12:28.257: ERROR/VoldConnector(67): No connection to daemon
03-19 00:12:28.257: ERROR/VoldConnector(67): java.lang.IllegalStateException
03-19 00:12:28.257: ERROR/VoldConnector(67):     at com.android.server.NativeDaemonConnector.sendCommand(NativeDaemonConnector.java:191)
03-19 00:12:28.257: ERROR/VoldConnector(67):     at com.android.server.NativeDaemonConnector.sendCommand(NativeDaemonConnector.java:178)
03-19 00:12:28.257: ERROR/VoldConnector(67):     at com.android.server.NativeDaemonConnector.doCommand(NativeDaemonConnector.java:213)
03-19 00:12:28.257: ERROR/VoldConnector(67):     at com.android.server.NativeDaemonConnector.doListCommand(NativeDaemonConnector.java:258)
03-19 00:12:28.257: ERROR/VoldConnector(67):     at com.android.server.MountService$2.run(MountService.java:425)
03-19 00:12:29.322: ERROR/SoundPool(67): error loading /system/media/audio/ui/Effect_Tick.ogg
03-19 00:12:29.338: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressStandard.ogg
03-19 00:12:29.347: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressSpacebar.ogg
03-19 00:12:29.411: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressDelete.ogg
03-19 00:12:29.427: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressReturn.ogg
03-19 00:13:31.174: ERROR/Zygote(32): setreuid() failed. errno: 2
03-19 00:13:43.834: ERROR/Zygote(32): setreuid() failed. errno: 17
03-19 00:13:46.234: ERROR/BatteryService(67): usbOnlinePath not found
03-19 00:13:46.234: ERROR/BatteryService(67): batteryVoltagePath not found
03-19 00:13:46.234: ERROR/BatteryService(67): batteryTemperaturePath not found
03-19 00:13:46.284: ERROR/SurfaceFlinger(67): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
03-19 00:13:57.094: ERROR/EventHub(67): could not get driver version for /dev/input/mouse0, Not a typewriter
03-19 00:13:57.104: ERROR/EventHub(67): could not get driver version for /dev/input/mice, Not a typewriter
03-19 00:13:57.475: ERROR/System(67): Failure starting core service
03-19 00:13:57.475: ERROR/System(67): java.lang.SecurityException
03-19 00:13:57.475: ERROR/System(67):     at android.os.BinderProxy.transact(Native Method)
03-19 00:13:57.475: ERROR/System(67):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
03-19 00:13:57.475: ERROR/System(67):     at android.os.ServiceManager.addService(ServiceManager.java:72)
03-19 00:13:57.475: ERROR/System(67):     at com.android.server.ServerThread.run(SystemServer.java:184)
03-19 00:13:59.354: ERROR/SoundPool(67): error loading /system/media/audio/ui/Effect_Tick.ogg
03-19 00:13:59.374: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressStandard.ogg
03-19 00:13:59.404: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressSpacebar.ogg
03-19 00:13:59.413: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressDelete.ogg
03-19 00:13:59.413: ERROR/SoundPool(67): error loading /system/media/audio/ui/KeypressReturn.ogg
03-19 00:14:04.984: ERROR/ThrottleService(67): Could not open GPS configuration file /etc/gps.conf
03-19 00:14:07.064: ERROR/logwrapper(147): executing /system/bin/tc failed: No such file or directory
03-19 00:14:07.135: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
03-19 00:14:07.204: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory

2 个答案:

答案 0 :(得分:2)

由于字符串是对象,因此不应将字符串与==进行比较。相反,您应该使用lvl.equals("2")

此外,使用break;语句完成每个案例。否则你的案例下面的代码也会被执行。

答案 1 :(得分:1)

我注意到的一些事情。

1)每个break;的末尾都没有case:个语句。您是否打算让执行从R.id.play流向R.id.level再到R.id.setLevel

2)您在setContentView(R.layout.level);案例的开头和R.id.level案例之前致电R.id.setLevel。一个电话就是我所见过的。两个电话有原因吗?我认为第二次通话可能会重置您的任何更改。