2016-06-28 105 views
0

我用選擇的複選框,它的工作原理,但它會導致預棒棒糖版本如何在選擇器中使用svgs用於pre lolipop版本?

<selector xmlns:android="..."> 
    <item android:state_checked="true" 
     android:drawable="@drawable/checked_icon" /> 
    <item android:drawable="@drawable/icon" /> 
</selector> 




<CheckBox 
android:button="@drawable/terms_checkbox"/> 

它會導致resourcNotFoundexception,如何解決這個問題的問題,有什麼解決辦法嗎?

致命異常:主要 android.view.InflateException:二進制XML文件行#70:錯誤充氣類複選框

 at dalvik.system.NativeStart.main(Native Method) 
                    Caused by: android.content.res.Resources$NotFoundException: File res/drawable/terms_service1.xml from drawable resource ID #0x7f020121 
                     at android.content.res.Resources.loadDrawable(Resources.java:2096) 
                     at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 

                     at android.widget.CompoundButton.<init>(CompoundButton.java:74) 
                     at android.widget.CheckBox.<init>(CheckBox.java:68) 


Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector 
                    at android.graphics.drawable.Drawable.createFromXmlInner(Draw 
+0

對我的作品中的Android 4.3版。 – sJy

+0

我在模擬器上測試android版本4.3.1 android.content.res.Resources $ NotFoundException: –

+0

Gradle中使用的buildToolsVersion是什麼? – sJy

回答

0

試試這個。

CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox); 
    Drawable d = AppCompatDrawableManager.get().getDrawable(this, R.drawable.terms_checkbox); 
    checkBox.setButtonDrawable(d); 
相關問題