android


selector is not working by TypedArray


I'm coding a custom view.
This view support param by outside.
I declare my style like this:
<declare-styleable name="Banner">
<attr name="indicatorSize" format="dimension"/>
<attr name="indicatorSelector" format="reference"/>
<attr name="defaultPic" format="reference"/>
</declare-styleable>
The indicatorSelector is Selector.
More Detail :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/shape_indicator_checked" android:state_checked="true" />
<item android:drawable="#drawable/shape_indicator_normal" />
</selector>
My activity layout.xml :
<com.push.vain.bannerview.view.BannerView
android:id="#+id/bannerView"
android:layout_width="match_parent"
android:layout_height="100dp"
banner:indicatorSize="5dip"
banner:indicatorSelector="#drawable/selector_indicator"
banner:defaultPic="#mipmap/ic_launcher"
/>
In my view class :
private void loadAttr(Context context, AttributeSet attrs) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Banner);
mIndicatorSize = array.getDimensionPixelSize(R.styleable.Banner_indicatorSize, 5);
mIndicatorSelector = array.getDrawable(R.styleable.Banner_indicatorSelector);
mDefaultPic = array.getDrawable(R.styleable.Banner_defaultPic);
array.recycle();
}
I want to get my selector object.
I write this : array.getDrawable(R.styleable.Banner_indicatorSelector);get mIndicatorSelector this param.
mIndicatorSelector is a Drawable.
This Drawable is a Selector.
And set it to my view's background:
private RadioButton createIndicator() {
RadioButton indicator = new RadioButton(getContext());
indicator.setButtonDrawable(android.R.color.transparent);
indicator.setClickable(false);
indicator.setBackground(mIndicatorSelector);
indicator.setBackground(mIndicatorSelector);this line is not working !
but this line just replace for
indicator.setBackgroundResource(R.drawable.selector_indicator)
is working.
But why ?

Related Links

How to send update SQLite table from one to everyother
Android Google Maps LocationClient
Foreground service that stops running
Javac doesn't create native .c file from .java. JNI
Text field from a ListView
Android SQLite best practice for memory performance
SQLiteDatabase.loadLibs Fatal signal 11 when using x86 native library
ffmpeg Build Output is not showing?
How to support ui for different medias like iphones,tablets,android phones
List Row not updated with use of Dialog
Check the fist item of my ListView
Pass data from Activity to fragment
connection from Android device to pc using socket? [duplicate]
Android stop notification in status bar while receiving message
how to display map using mapview
DatePicker dialog after reselecting datepicker shows current date

Categories

HOME
algorithm
phantom-dsl
eclipse
developer-tools
merge
nunit
3d
apache-spark-mllib
solaris
spring-data-mongodb
emscripten
pyqt4
jquery-ui
android-json
sendgrid-api-v3
project
mql5
32bit-64bit
openpyxl
mxgraph
event-sourcing
internationalization
microsoft-dynamics-nav
html5-appcache
cfml
enterprise-miner
asp.net-core-webapi
replication
inno-download-plugin
joptionpane
flask-sqlalchemy
perlbrew
game-theory
data.stackexchange.com
fable-f#
corpus
appirater
tpm
failover
event-flow
sql-server-2000
cart
catch-unit-test
github3.py
dynamic-jasper
searchkit
google-knowledge-graph
attributeerror
postgresql-8.4
knime
show-hide
openal
tinkerpop
er-diagram
oozie-coordinator
janus
py2neo
shinobi
javafx-css
meteor-packages
webjars
async.js
watch-os-2
neon
android-wake-lock
project-organization
hadoop-partitioning
boost-serialization
lz77
grass
false-sharing
jbase
iokit
opserver
atoi
airbrake
linked-tables
apache-commons-daemon
mmwormhole
mass-assignment
ssis-data-flow
sql-scripts
linkedin-jsapi
jama
build-script
scrypt
time.h
chart-director
booksleeve
extreme-programming
onmousemove
qtconcurrent
adobe-media-server
paginator
fusefabric
jquery-address
google-maps-mobile
agility.js
workflow-services
landscape-portrait
android-holo-everywhere
update-statement
twitterizer
timertask
uideviceorientation
openfaces
sifr
burndowncharts
lalr
application-planning
firefox-3
change-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App