码迷,mamicode.com
首页 > 其他好文 > 详细

setCompoundDrawablesRelativeWithIntrinsicBounds

时间:2014-08-08 13:04:46      阅读:1370      评论:0      收藏:0      [点我收藏+]

标签:android   java   使用   os   io   for   art   ar   

android 2.2 无法使用:setCompoundDrawablesRelativeWithIntrinsicBounds

错误代码:

 FATAL EXCEPTION: main
 java.lang.NoSuchMethodError: android.widget.RadioButton.setCompoundDrawablesRelativeWithIntrinsicBounds
  at com.vkoov.zjth.LatestActivity01.onResume(Unknown Source)
  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
  at android.app.Activity.performResume(Activity.java:3823)
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:170)
  at android.app.LocalActivityManager.dispatchResume(LocalActivityManager.java:518)
  at android.app.ActivityGroup.onResume(ActivityGroup.java:58)
  at com.vkoov.YaloeActivity.onResume(Unknown Source)
  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
  at android.app.Activity.performResume(Activity.java:3823)
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4627)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
  at dalvik.system.NativeStart.main(Native Method)

解决办法:

int sysVersion = Integer.parseInt(VERSION.SDK);
   if (sysVersion < 14) {
    drawable.setBounds(0, 0, 30,30);
    ((RadioButton) (getParent().findViewById(R.id.main_tab_zjth)))
      .setCompoundDrawables(null, drawable, null, null);
   } else {
    ((RadioButton) (getParent().findViewById(R.id.main_tab_zjth)))
      .setCompoundDrawablesRelativeWithIntrinsicBounds(null,
        drawable, null, null);
   }

setCompoundDrawablesRelativeWithIntrinsicBounds,布布扣,bubuko.com

setCompoundDrawablesRelativeWithIntrinsicBounds

标签:android   java   使用   os   io   for   art   ar   

原文地址:http://my.oschina.net/arrom/blog/299160

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!