android


How to edit Widget.Spinner press effect for color change in Android


I am using
following style to show spinner which is having custom style
<TableRow
android:id="#+id/tblRwSpn11"
style="#style/TableRowStyle" >
<Spinner
android:id="#+id/btnDashCust1"
style="#style/ButtonStyleSpinner1"
android:layout_marginTop="5dp"
android:layout_span="2"
android:textSize="10sp" />
</TableRow>
<style name="ButtonStyleSpinner1" parent="#android:style/Widget.Spinner">
<item name="android:textColor">#color/black</item>
<item name="android:layout_height">35dp</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:textSize">#dimen/twelveTextSize</item>
</style>
in my SDK style.xml
<style name="Widget.Spinner">
<item name="android:background">#android:drawable/btn_dropdown</item>
<item name="android:clickable">true</item>
<item name="android:spinnerMode">dialog</item>
<item name="android:dropDownSelector">#android:drawable/list_selector_background</item>
<item name="android:popupBackground">#android:drawable/spinner_dropdown_background</item>
<item name="android:dropDownVerticalOffset">-10dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
<item name="android:popupPromptView">#android:layout/simple_dropdown_hint</item>
<item name="android:gravity">center</item>
</style>
and #android:drawable/btn_dropdown as follows
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false" android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_normal" />
<item
android:state_window_focused="false" android:state_enabled="false"
android:drawable="#drawable/btn_dropdown_disabled" />
<item
android:state_pressed="true"
android:drawable="#drawable/btn_dropdown_pressed" />
<item
android:state_focused="true" android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_selected" />
<item
android:state_enabled="true"
android:drawable="#drawable/btn_dropdown_normal" />
<item
android:state_focused="true"
android:drawable="#drawable/btn_dropdown_disabled_focused" />
<item
android:drawable="#drawable/btn_dropdown_disabled" />
</selector>
output :
My Theme
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/thin_ab_style</item>
</style>
<style name="MyActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:background">#color/blue</item>
<item name="android:actionBarSize">2dp</item>
</style>
<style name="thin_ab_style" parent="android:Widget.Holo.ActionBar">
<item name="android:height">30dp</item>
<item name="android:background">#color/blue</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">#color/white</item>
</style>
it shows orange color for my spinner even if i have not set
so from where it is getting set? Please check above styles I applied to spinner
the press effect should show either blue or gray according to theme
Just write a basic Adapter extends ArrayAdapter<Type> like doing as List View.
Override getView method for that view that you want to change.
Override getDropDown view that opened when spinner pressed.
Lastly dont forget to call Spinner.setAdapter(mAdapter)
And you can use your custom layouts to change colors or anything you want.
Good luck there.

Related Links

Android opengl.Matrix class issue
How can I lock whitespace characters from the text field in real time?
Nexus 7 Android File Transfer (Socket Programming in Android)
How to export phonegap local database data into csv/excel file in android app?
Detetecting an ips camera present in my wifinet work
Issue while displaying action bar with title in android 4.0 or higher
Android- Chat application - Convert editbox emoticons in string ;) format to save in database
unstable cellid coordinates with google/glm/mmap
How to Passing Iterates Data to setOnInfoWindowClickListener
Android rss (rss 2.0 and atom ) parse error : line xxx column xxx:not well-formed (invalid token)
Flurry mediation with many Ad Networks
Android go back to main activity and get intent data
Adding Buttons dynamically to a Android popup Window
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 9
How can I check if somebody answers my call in Android [duplicate]
Device Admin API sample: works fine on emulator NoSuchMethod error on Device

Categories

HOME
cheerio
pyqt
static
mstest
gradient
google-apps
parameters
regular-language
nfs
g++
openstreetmap
commonjs
vimdiff
emoji
automatic-ref-counting
http-post
standards
asp.net-mvc-viewmodel
soci
symfony-console
microsoft-ocr
asciidoctor-pdf
guzzle
jquery-ias
pagespeed
zxing
expressionengine3
android-sharedpreferences
jackson-modules
angularjs-components
flooding
nsurl
constexpr
complex-numbers
paragraph
autolisp
spring-security4
simplecv
wacom
card.io
hard-drive
hunspell
carriage-return
google-earth-engine
tex
apache-stanbol
sharp-snmp
clang++
stylecop
phpdbg
openresty
opennms
activeperl
zenhub
tinkerpop
appdomain
backbone-collections
edit
android-testing
headless
ngmaterial
dt
cup
otp
pdf-conversion
cmp
taocp
reporting-services-2012
greatest-n-per-group
mta
model-associations
jboss-tools
refinerycms
stream-processing
fink
beanstalk
relativelayout
iokit
dock
eoferror
botan
fail2ban
entity-framework-4.3
umlgraph
cryptographichashfunction
primitive-types
big-ip
appserver
universal-image-loader
nsmenu
raygun
encryption-asymmetric
personalization
gd-graph
inputmismatchexception
ebay-lms
cnf
epiceditor
font-awesome-4.0.0
asplinkbutton
pstack
saleslogix
iboutlet
inkcanvas
mapping-by-code
usertype
hibernateexception
cfwindow
build-environment
asynchronous-wcf-call
idatareader

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App