mardi 16 juin 2015

android checkbox drawable crashing app

i'm kinda new to android and i am following other questions and answers on stack overflow and i feel like i am getting close, But i can't get it to work. when i tried it crashes my app.

just to test it's functionality i am using http://ift.tt/1ekNNSs

and

http://ift.tt/1cYFv0Y

and my code has a cb_selector in a drawable folder.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://ift.tt/nIICcg">
    <item
        android:state_checked="true"
        android:drawable="@drawable/checkbox_checked"
        android:color="#000000" />
    <!-- checked -->
    <item
        android:state_checked="false"
        android:drawable="@drawable/checkbox_empty"
        android:color="#000000"/>
    <!-- unchecked -->
    <item
        android:state_focused="true"
        android:color="#000000"/>
    <!-- on focus -->
    <item android:color="#000000"/>
    <!-- default -->
</selector>

and my checkbox is:

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/ownit_text"
        android:id="@+id/switch_ownit"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_toEndOf="@id/imageView_amiibo"
        android:layout_toRightOf="@+id/imageView_amiibo"
        android:layout_below="@+id/textView_amiiboName"
        android:background="@drawable/cb_selector"/>

on the android ADK website it uses android:textColor="" and android:background="" on stack overflow someone has said to use android:button=""

when i use background or button it crashes. and when i use textcolor it just affects the checkboxes label and does not change the drawable.




Aucun commentaire:

Enregistrer un commentaire