android


Shared Preferences Drawable color Android


Hello I'm using Shared Preferences to store colors of the APP.
Until now I can save the colors of the button and status bar because they don't use drawable colors.
This is are my functions:
private void storeColor(int color){
SharedPreferences mSharedpreferences = getSharedPreferences("ToolbarColor", MODE_PRIVATE);
SharedPreferences.Editor mEditor = mSharedpreferences.edit();
mEditor.putInt("color", color);
mEditor.apply();
}
private int getColor(){
SharedPreferences mSharedPreferences = getSharedPreferences("ToolbarColor", MODE_PRIVATE);
int selectedColor = mSharedPreferences.getInt("color", getResources().getColor(R.color.colorPrimary));
return selectedColor;
}
And I'm using them like this:
if (intValue == 1){
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.green_apple));
btn_historial.setBackgroundColor(getResources().getColor(R.color.green_apple));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(getResources().getColor(R.color.green_apple));
}
storeColor(getResources().getColor(R.color.green_apple));
}
if(getColor() != getResources().getColor(R.color.colorPrimary)){
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.colorPrimary));
btn_historial.setBackgroundColor(getColor());
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(getColor());
}
}
Before I was using toolbar, but now I want to use the action bar.
I'm a little lost here How can I add drawable colors here?
Use a ColorDrawable.
int color = getColor();
getActionBar().setBackgroundDrawable(new ColorDrawable(color));

Related Links

WebView text size
Better HTML Formatting
Android - determine number of fingers touching
can getting sensor data take less CPU time?
automatically zoom out the image after Zoom in the image
iPhone Android : Memory Handling , which one uses more memory ?
Issue on sending MMS in Android version 4.0.3
How to escape special characters like ' in sqlite in android
Creating a youtube video list, and saving the links for use offline
Why did RecognitionListener stop working in JellyBean?
How to properly name native functions when using the NDK
Dynamic interface using TableRows
Stop Location Service
How to show dialog box from asyntask nonUI activity in android?
Android Clip image to bounds
Change Android quicksshd to listen to the public ip

Categories

HOME
cygwin
design-patterns
developer-tools
ng-idle
alexa-skills-kit
pascal
jwplayer
switch-statement
nested-if
settings
iis-6
google-cloud-datalab
angularfire2
barcode
google-chrome-app
gson
supervisor
enterprise-architect
oledb
replication
windows-xp
rubymotion
libigl
mongoid6
aggregation
beautifier
stackexchange
pylons
oculus
iis-express
recurring-events
postback
kudu
mockjax
git-squash
memory-address
clickjacking
card.io
vue-chartjs
arduino-ide
baidu-map
processwire
visa
plaintext
apollostack
rfc3339
mesosphere
dynamic-linq
magento-2.0.7
dotnet-httpclient
fclose
spring-data-couchbase
dt
otp
d3-force-directed
objectscript
jtree
visual-studio-2008-sp1
findfirst
halcon
httpruntime.cache
rasterize
vhosts
dynatree
jdi
roadkill-wiki
ess
page.js
snoop
node-serialport
shopizer
mass-assignment
pseudo-class
buffering
authlogic
menubar
android-audiorecord
spring-3
mt4j
windows-phone-8-sdk
kogrid
route-provider
traceability
stacky
android-sdk-2.3
redis-py
wcf-configuration
catransform3d
xcelsius
drawtobitmap
xui
svk
objective-j
load-time
dot-emacs
murmurhash
echo3
software-lifecycle
cardspace

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