0
이미지 버튼에 이미지를 추가하려고합니다. 내 button.xml 그래서 다음과 같습니다드로어 블을 해결할 수 없습니다
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true" android:drawable="@drawable/button_pressed" />
<item
android:state_focused="true" android:drawable="@drawable/button_focused" />
<item
android:drawable="@drawable/button_normal" />
</selector>
그리고 내 main.xml에 그렇게 다음과 같습니다
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton
android:src="@drawable/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
그리고 내 오류가 너무 다음과 같습니다
org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:151)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:749)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:695)
at com.android.layoutlib.bridge.ResourceHelper.getDrawable(ResourceHelper.java:145)
at com.android.layoutlib.bridge.BridgeTypedArray.getDrawable(BridgeTypedArray.java:662)
at android.widget.ImageView.<init>(ImageView.java:113)
at android.widget.ImageButton.<init>(ImageButton.java:51)
at android.widget.ImageButton.<init>(ImageButton.java:47)
내가 이해 오류는 button.xml의 첫 번째 "item"태그에 중점을 둡니다. main.xml에서 src를 백그라운드로 변경하려고 시도했지만 button.xml에서 drawable을 백그라운드로 변경하려고 시도했지만 매번 같은 오류가 발생합니다.
신난다, 단순히 최고. 선생님이나 부인 께 감사드립니다. – Jodron
그건 선생님입니다. :) 문제는 없지만 문제가 해결 된 경우 답변을 수락 된 것으로 표시하십시오. – andrrs
15의 담당자 없이는 그렇게 할 수 없습니다. ( – Jodron