के आधार पर एक्शनबार मेनू आइकन बदलें, मैं किस शैली का उपयोग (डार्क या लाइट) के आधार पर विभिन्न ActionBar
आइकन का उपयोग करना चाहता हूं। मैं यह पता लगा सकता है कि कैसे, मैं यहाँ क्या करने की कोशिश की:स्टाइल
<style name="AppThemeDark" parent="Theme.Sherlock.ForceOverflow">
<item name="android:actionButtonStyle">@style/customActionButtonStyleDark</item>
<item name="actionButtonStyle">@style/customActionButtonStyleDark</item>
</style>
<style name="AppThemeLight" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="android:actionButtonStyle">@style/customActionButtonStyleLight</item>
<item name="actionButtonStyle">@style/customActionButtonStyleLight</item>
</style>
<style name="customActionButtonStyleDark" >
<item name="@drawable/action_search">@drawable/action_search</item>
</style>
<style name="customActionButtonStyleLight" >
<item name="@drawable/action_search">@drawable/action_search_light</item>
</style>
मैं भी <item name="@drawable/action_search">@drawable/action_search</item>
विषय शैली में सीधे सम्मिलित करने की कोशिश की, लेकिन कुछ भी काम किया।
कोई विचार कैसे?
यह ठीक काम कर रहा है के लिए, चलो धन्यवाद! लेकिन जावा से इसका उपयोग कैसे करें? जब मैं menuLetters.setIcon (R.attr.ic_action_messages) को कॉल करता हूं; मुझे त्रुटि मिलती है कि संसाधन नहीं मिला। – BArtWell
अच्छा सवाल, मुझे लगता है कि जवाब [यहां] है (http://stackoverflow.com/questions/8793183/access-resource-defined-in-theme-and-attrs-xml-android)। चाल यह प्रतीत होती है कि आपको एंड्रॉइड को यह बताना है कि वर्तमान में कौन सी थीम सेट की गई है, इसलिए यह जानता है कि किस स्टाइल संसाधन को पकड़ना है। –
हाँ, आप सही हैं, यह भी ठीक काम कर रहा है। धन्यवाद! – BArtWell