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

Do common JARs have to be repeated accross WARs in an EAR?
Important frameworks/tools to learn
What are the lightweight options one has to persist Java objects [closed]
How do I make the method return type generic?
batch not working if calling from a Java program
Best way to list files in Java, sorted by Date Modified?
Log4j usage - how to customize the event ID when logging to Windows Event Log?
Running junit tests in parallel in a Maven build?
Java and CANopen
how to control focus in JTable
CodeBetter.com like blogs for Java [closed]
Vehicle tracking system/Jan08
Java postal address parser [closed]
How to select first item in JPopupMenu?
How can a JComponent notified about the closed event of it's parent J(Internal)Frame?
Test for invertability using Jama.Matrix

Categories

HOME
wso2
amazon-ec2
oracle11g
heroku
comparison
hashmap
vmware
read-eval-print-loop
rsyslog
rubygems
survey
gps
umd
icloud
sql-server-2016
ezpublish
networkx
contact
mapserver
zend-framework3
clearcase-ucm
ghc
saxon
serilog
jqwidget
nas
ml
web-sql
chromium-embedded
language-agnostic
h2db
fluentvalidation
msys2
skia
react-chartjs
copying
typed.js
html5-fullscreen
restlet
multilingual
dism
gzipstream
dynamic-reports
jvm-languages
keydown
total-commander
import-from-excel
modelmapper
python-c-api
logparser
veracode
rdfs
elgg
brightcove
directory-structure
typed-lambda-calculus
hittest
topbeat
watchconnectivity
setuptools
nxt
passport-google-oauth
url-masking
gridview-sorting
apachebench
goose
photobucket
vhd
xna-4.0
lib.web.mvc
mutation-observers
rgeo
generic-programming
nsight
skos
truevault
geonetwork
website-monitoring
winddk
file-copying
qcodo
gulp-less
zend-route
eol
tld
htmlcleaner
valuechangelistener
hippomocks
braille
terminal-services
quartz-graphics
xamlparseexception
pygit2
jelly
labwindows
tridion-worldserver
hosts-file
regsvr32
postgresql-performance
amazon-appstore
spring-portlet-mvc
asyncfileupload
code-cleanup
netdna-api
eclipse-templates
locationlistener
h.323
mozilla-prism
gin
xsdobjectgen
ncqrs
privilege
simpletest
mediarss
zune

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