2012-08-30 14 views
8

Tôi không thể ghi đè android: switchStyle. Dưới đây là những gì tôi đã làm:Không thể ghi đè kiểu chuyển đổiStyle và NumberPicker trong Android

Trong thư mục giá trị-v14, tôi có hai tập tin:

themes.xml:

<style name="AppTheme" parent="android:Theme.Holo.Light"> 
    <item name="android:switchStyle">@style/SwitchAppTheme</item> 
</style> 

styles.xml:

<style name="SwitchAppTheme" parent="android:Widget.Holo.Light.CompoundButton.Switch"> 
    <item name="android:track">@drawable/switch_track_holo_light</item> 
    <item name="android:thumb">@drawable/switch_inner_holo_light</item> 
</style> 

tôi có các lỗi sau:

res/values-v14/styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.CompoundButton.Switch'.

res/values-v14/themes.xml:5: error: Error: No resource found that matches the given name: attr 'android:switchStyle'.

Tôi đã có cùng một vấn đề với NumberPicker:

themes.xml:

<item name="android:numberPickerUpButtonStyle">@style/NumberPickerButtonUpAppTheme</item> 
<item name="android:numberPickerDownButtonStyle">@style/NumberPickerButtonDownAppTheme</item> 
<item name="android:numberPickerStyle">@style/NumberPickerAppTheme</item> 

styles.xml:

<style name="NumberPickerButtonUpAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerUpButton"> 
    <item name="android:src">@drawable/numberpicker_up_btn_holo_light</item> 
</style> 

<style name="NumberPickerButtonDownAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerDownButton"> 
    <item name="android:src">@drawable/numberpicker_down_btn_holo_light</item> 
</style> 

tôi có các lỗi sau đây:

/res/values-v11/themes.xml:26: error: Error: No resource found that matches the given name: attr 'android:numberPickerStyle'.

/res/values-v11/themes.xml:25: error: Error: No resource found that matches the given name: attr 'android:numberPickerDownButtonStyle'.

/res/values-v11/themes.xml:25: error: Error: No resource found that matches the given name: attr 'android:numberPickerUpButtonStyle'.

Dự án của tôi sử dụng SDK 16, vì vậy nó sẽ có sẵn ... Lỗi tương tự trong nhật thực và IntelliJ.

Làm cách nào để mở rộng các kiểu này? Tôi có thể mở rộng nhiều mục khác (buttonStyle, buttonStyleToggle, seekBarStyle ...) theo cách tương tự ...

+0

Chạy vào cùng một vấn đề chính xác. Có vẻ như nó đã được báo cáo là lỗi của Google. http://code.google.com/p/android/issues/detail?id=36636 –

+0

Có, tôi đã tạo lỗi vì tôi khá chắc chắn tôi đã không phạm sai lầm, nhưng tôi cũng đã tạo bài đăng này trong trường hợp của ai đó có bất kỳ ý tưởng nào ... –

+1

Bạn có thể kiểm tra các thuộc tính công khai bằng cách xem android.R.attr trên tài liệu. –

Trả lời

4

Kiểu dành cho tiện ích Chuyển đổi không công khai.

Bạn có thể sử dụng android-switch-backport hoặc SwitchCompatLibrary. Họ cũng làm việc với Android Holo Colors

Ngoài ra còn có một sự thay thế cho Picker Số: Better Pickers

Tôi hy vọng tôi là hữu ích.

+3

Cảm ơn tôi biết rằng, tôi là tác giả của Holo Colors;) Tôi hy vọng Google sẽ làm điều gì đó ... –

+0

Làm việc tốt với Màu Holo :) Chúng tôi không thể làm gì ngoại trừ bỏ phiếu/giải quyết vấn đề. – LordRaydenMK