2011-03-20 381 views
0

每當我點擊一個按鈕,在這裏什麼都不做是一些代碼(我用Log.d(),發現執行停止的setContentView(R.layout.play前右):Android模擬器的問題

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 
+1

我們可以得到比這更多的代碼嗎?還有'logcat'的錯誤? – 2011-03-20 00:02:24

+0

你好,你能告訴我什麼是lvl嗎?它是textview或編輯文本或其他東西? – 2011-03-20 04:17:14

回答

2

因爲字符串是對象,你不應該==比較字符串相反,你應該使用lvl.equals("2")

另外,用break;聲明完成每個案例。否則你的情況下面的代碼也會被執行。

+0

謝謝,但它仍不能解決問題 – 2011-03-20 00:40:25

+0

您能否在開關模塊中添加一些調試打印件,所以我們會看看它是否進入那裏? – MByD 2011-03-20 00:43:05

+0

對不起,呃....什麼是調試打印? – 2011-03-20 01:02:02

1

我注意到了一些事情。

1)您在每個case:末尾沒有break;聲明。您是否打算執行從R.id.playR.id.levelR.id.setLevel

2)您在R.id.level案件的開始處和R.id.setLevel案件的前面撥打setContentView(R.layout.level);。一個電話是我見過的。有兩個電話的理由嗎?我認爲第二個電話可能會重置您的任何更改。