android 가상 기기에 프로그램을 불러오는 중 오류 보고:android.widget.RelativeLayout cannot be cast to android.widget.Button

10862 단어 RelativeLayout
 1 05-23 02:53:48.416: E/Trace(875): error opening trace file: No such file or directory (2)

 2 05-23 02:53:52.545: E/AndroidRuntime(875): FATAL EXCEPTION: main

 3 05-23 02:53:52.545: E/AndroidRuntime(875): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intelsocket/com.example.intelsocket.MainActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.Button

 4 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

 5 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

 6 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread.access$600(ActivityThread.java:141)

 7 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

 8 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.os.Handler.dispatchMessage(Handler.java:99)

 9 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.os.Looper.loop(Looper.java:137)

10 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread.main(ActivityThread.java:5041)

11 05-23 02:53:52.545: E/AndroidRuntime(875):     at java.lang.reflect.Method.invokeNative(Native Method)

12 05-23 02:53:52.545: E/AndroidRuntime(875):     at java.lang.reflect.Method.invoke(Method.java:511)

13 05-23 02:53:52.545: E/AndroidRuntime(875):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

14 05-23 02:53:52.545: E/AndroidRuntime(875):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

15 05-23 02:53:52.545: E/AndroidRuntime(875):     at dalvik.system.NativeStart.main(Native Method)

16 05-23 02:53:52.545: E/AndroidRuntime(875): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.Button

17 05-23 02:53:52.545: E/AndroidRuntime(875):     at com.example.intelsocket.MainActivity.set_btn_status(MainActivity.java:275)

18 05-23 02:53:52.545: E/AndroidRuntime(875):     at com.example.intelsocket.MainActivity.onCreate(MainActivity.java:62)

19 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.Activity.performCreate(Activity.java:5104)

20 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

21 05-23 02:53:52.545: E/AndroidRuntime(875):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

22 05-23 02:53:52.545: E/AndroidRuntime(875):     ... 11 more

23 05-23 02:54:33.206: E/AndroidRuntime(913): FATAL EXCEPTION: main

24 05-23 02:54:33.206: E/AndroidRuntime(913): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intelsocket/com.example.intelsocket.MainActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.Button

25 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

26 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

27 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread.access$600(ActivityThread.java:141)

28 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

29 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.os.Handler.dispatchMessage(Handler.java:99)

30 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.os.Looper.loop(Looper.java:137)

31 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread.main(ActivityThread.java:5041)

32 05-23 02:54:33.206: E/AndroidRuntime(913):     at java.lang.reflect.Method.invokeNative(Native Method)

33 05-23 02:54:33.206: E/AndroidRuntime(913):     at java.lang.reflect.Method.invoke(Method.java:511)

34 05-23 02:54:33.206: E/AndroidRuntime(913):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

35 05-23 02:54:33.206: E/AndroidRuntime(913):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

36 05-23 02:54:33.206: E/AndroidRuntime(913):     at dalvik.system.NativeStart.main(Native Method)

37 05-23 02:54:33.206: E/AndroidRuntime(913): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.Button

38 05-23 02:54:33.206: E/AndroidRuntime(913):     at com.example.intelsocket.MainActivity.set_btn_status(MainActivity.java:275)

39 05-23 02:54:33.206: E/AndroidRuntime(913):     at com.example.intelsocket.MainActivity.onCreate(MainActivity.java:62)

40 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.Activity.performCreate(Activity.java:5104)

41 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

42 05-23 02:54:33.206: E/AndroidRuntime(913):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

43 05-23 02:54:33.206: E/AndroidRuntime(913):     ... 11 more

이곳의 이 잘못은 내가 이렇게 해결했다.
1   public void set_btn_status(boolean paramBoolean)//      

2   {

3     ((Button)findViewById(2131230727)).setEnabled(paramBoolean);

4     ((Button)findViewById(2131230728)).setEnabled(paramBoolean);

5     ((Button)findViewById(2131230729)).setEnabled(paramBoolean);

6     ((Button)findViewById(2131230730)).setEnabled(paramBoolean);

7   }

다음으로 변경:
1 public void set_btn_status(boolean paramBoolean)//      

2   {

3     ((Button)findViewById(R.id.ledonBtn)).setEnabled(paramBoolean);

4     ((Button)findViewById(R.id.ledoffBtn)).setEnabled(paramBoolean);

5     ((Button)findViewById(R.id.jdqonBtn)).setEnabled(paramBoolean);

6     ((Button)findViewById(R.id.jdqoffBtn)).setEnabled(paramBoolean);

7   }

좋은 웹페이지 즐겨찾기