java


Get a layout inflater from the ApplicationContext


I'm following that guide for implementing a custom preference. http://android-journey.blogspot.com/2010/01/for-almost-any-application-we-need-to.html. In the method
#Override
protected View onCreateView(ViewGroup parent){
...
}
The guide creates the elements programmatically and then returns the view. I'd like retrieve the layout from a xml file. But the call getLayoutInflater() is not accesible there how can I retrieve a layout inflater for get the view stored in the file "progressbarpreference.xml"?
I have a static reference to the application Context available if needed
Thanks
LayoutInflater inflater = LayoutInflater.from(this);
inflater.inflate(R.layout.yourcustomviewxml, layout);
Got this from a question I asked: How to pass AttributeSet to custom View Thanks Ian!
LayoutInflater li = (LayoutInflater) ctx.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
should do the trick (ctx is your application context in this case).
Use the static reference, suppose if it is context.
rowLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.progress_bar, parent, false);
where progress_bar is the id of the linear layout.

Related Links

#Pattern annotation for a method parameter
Set the time-of-day on a ZonedDateTime in java.time?
Why java.lang.NoSuchMethodError when dynamically load a dex jar?
Elastic Search - How to perform IN condition in elastic search
SB - How to provide a hibernate.cfg.xml file to a LocalSessionFactoryBuilder?
Query list based on input list value
dalvikvm: Could not find class 'android.*
How to reset the value of an inputText to the original value on rowUnselectCheckbox
How to get value by key from json? Java
Fast way to convert BufferedImage to Jpeg
Viewpager + button to new Activity
Convert JSON to Java class (call WebApi from Android app)
Save hash map Shared Preferences
The Tomcat server is running properly but still error 404 is generated [closed]
Displaying swing components with a loop
Unable to connect Cassandra 3.0 using Spark cassandra connector 1.5.0

Categories

HOME
blogger
gerrit
yahoo-oauth
analysis
leon
graphql
electronics
sqlite3
jxls
facebook-messenger-bot
user-input
volttron
izpack
google-apps-marketplace
quickfix
graphlab
viewport
grails3
intentfilter
arabic
css-animations
mustache.php
kudan
language-agnostic
p-value
vlsi
tdd
pepper
ping
phonegap
commit
mapbox-gl
jmonkeyengine
retina-display
neuroscience
starteam
c11
trim
broadcastreceiver
preconditions
wptoolkit
cubic-spline
xml-documentation
dds
dropbox-php
slickedit
magma
sybase-asa
boost-preprocessor
arrow-keys
nbconvert
vtigercrm
heidisql
trash
xml-attribute
ubuntu-10.04
qgraphicsview
wapiti
unity-networking
wso2cloud
execute
google-places
simple-framework
embedded-code
microbenchmark
qcodo
java-metro-framework
elliptic-curve
fmod
intentservice
gridfs
soundtouch
cos
flashvars
ocunit
selected
trusted
onsubmit
dbproviderfactories
qtkit
spring-portlet-mvc
doh
deobfuscation
ecl
paster
modelstate
brewmp
exchange-server-2003
backcolor
thread-local-storage
windows-live-messenger

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