kellogs wrote:
> issue 1: every time we want to bind an ArrayAdapter to a data setm we
> construct an ArrayAdapter object that ALWAYS searches an .xml layout
> for a TextView resource. (that is if we do not deliberately instruct
> the constructor upon the exact TextView we want to use from a .xml
> layout file). Yet, documentation tells us to 'override getView(int,
> View, ViewGroup) to return the type of view you want'. Sow how is
> Android going to fit some huge composite View into a TextView ?
AFAIK, if you override getView() in any adapter class, the resource ID
you provide in the constructor is ignored. That doesn't prevent you from
using ViewInflate with that resource ID, or any other, in your own
getView() implementation.
> issue 2: my overriden getView (...) is:
>
> public View getView(int position, View convertView, ViewGroup parent)
> {
> View singleView;
> if (position % 2 == 0)
> {
> OvalShape circle = new OvalShape();
> circle.resize(6, 6);
> ShapeDrawable dwb = new ShapeDrawable (circle);
> dwb.setColor(100);
> singleView = new ImageView (getContext());
> ((ImageView)singleView).setPreferredHeight(10);
> ((ImageView)singleView).setPreferredWidth(10);
> ((ImageView)singleView).setImageDrawable(dwb);
>
> //parent.addView(singleView);
> super.getView(position, singleView, parent);
> return (ImageView)singleView;
> } else {
> singleView = new TextView (getContext());
> ((TextView)singleView).setPreferredHeight(10);
> ((TextView)singleView).setPreferredWidth(210);
>
> //parent.addView(singleView);
> super.getView(position, singleView, parent);
> return (TextView)singleView;
> }
>
> What I was expecting was one line of ImageView, one of TextView, one
> Image, one Text, etc. However, calling the supper.getView(...) throws
> a classCastException, and if I try manually adding the view with
> parent.addView(..) and comment out the super.getView(..), I get an
> IllegalStateException. Were my expectations right ?
Don't call super.getView(). You want to override it completely and do
not want the superclass' implementation.
With regards to the IllegalStateException, without a trace or something,
I can't comment. But that doesn't matter -- I'd recommend tossing out
all that code and going with:
> issue 3: Well, If I will get past he first 2 issues, I would like to
> make a container for the Image and Text and display that one as a
> row... however, Android pretty much sux ass at dynamic UI.
Which is why you shouldn't be using it.
Use a graphics program to make yourself your dots, make yourself a
layout with an ImageView (for the dot) and TextView inside a
LinearLayout or something, and if convertView is null in your getView()
implementation use ViewInflate in order to turn the XML into the proper
View object. Then fill in the View (either the one you created or
convertView) with the data.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions, & ebook formats, just $35/year
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---