Tôi đã theo dõi this tutorial để tạo danh sách trạng thái màu cho chế độ xem Android cụ thể. Tôi chỉ muốn nó làm nổi bật khi được nhấp để người dùng biết tại sao màn hình chỉ thay đổi.Tuyến tính AndroidThanh toán với tài nguyên màu: Tôi đang làm gì sai?
Khi xem là ra, tôi nhận được lỗi sau:
org.xmlpull.v1.XmlPullParserException: dòng tập tin XML Binary # 3: thẻ đòi hỏi một thuộc tính hoặc con tag 'drawable' xác định một drawable
My XML màu (trong res/màu/viewcolor.xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#ff33ffff"/> <!-- pressed -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
bố trí của tôi XML (trong res/layout/myview.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myview"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:background="@color/viewcolor">
<!--crap in the layout-->
</LinearLayout>
Tôi đã bỏ lỡ điều gì?
nếu ai đó muốn có được giải pháp đầy đủ, kiểm tra kho lưu trữ này: https://github.com/shamanland/AndroidLayoutSelector có tùy chỉnh có thể click/checkable '' 'LinearLayout''' như một' '' ToggleButton''' –