Moto wrote:
> Hello currently I'm making my custom ListAdapter and I add my Text
> Views the following way:
> 
> LinearLayout.LayoutParams radioParams = new LinearLayout.LayoutParams
> (320,          LayoutParams.FILL_PARENT);
> 
> radioParams.setMargins(1, 1, 1, 1);
> TextView stationName = new TextView( context );
> stationName.setText( radioInfo.getStationName() );
> stationName.setTextSize(14f);
> stationName.setTextColor(Color.WHITE);
> addView( stationName, radioParams);
> 
> 
> I already have a layout that I want to use for each element
> essentially would be nice if I could just call something like:
> 
> setContentView(R.layout.station_list_element);
> 
> or
> 
> LinearLayout radioParams = new LinearLayout(context,
> R.layout.station_list_element );
> radioParams.textNowPlaying= "Chemical Brothers"
> 
> 
> So that for sure that won't work but how can I create a LinearLayout
> and import my settings which are on my xml? Then how could I access
> the individual fields to update the text on them?

getLayoutInflater().inflate() will inflate an XML layout, returning to
you the root View of the layout. From there, calling findViewById() on
the root View of the layout will give you access to Views within that
layout.

You can see examples of all of this, in the context of custom
ListAdapters, in my Fancy ListViews blog series over on AndroidGuys:

http://androidguys.com/?s=fancy+listviews

Most of the earlier ones in the series are for the older M5 SDK, but the
concepts still hold. Also, forgive the formatting -- AndroidGuys updated
their WordPress theme and my older posts are a bit malformed as a result.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.9 Available!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to