AdapterView is really there to provide common implementation for ListView and GridView. If you want to make your own class deriving from AdapterView, you probably want to look at the implementation of those classes to understand what you need to do.
On Mon, Feb 16, 2009 at 5:38 PM, drasticp <[email protected]> wrote: > > I'm creating a custom widget that extends AdapterView. Imagine > something like a ListView except that the list items can overlap each > other with some transparency. Because of the overlap, I'm trying to > control the layout and drawing order of the children. > > My issue is that the control renders it's children, but ONLY one level > deep. Each child is inflated from an XML resource that contains a > FrameLayout and an ImageView. The FrameLayout draws, but the ImageView > is never visible. I assume I need to call some method to tell the > FrameLayout to layout or draw it's children, but I'm not sure what, > why, or where. Does anyone know what I'm missing? > > Here is the relevant code for my custom widget: > > public class MagicList extends AdapterView<Adapter> > { > // blah stuff omitted... > > @Override > protected void onLayout(boolean changed, int l, int t, int r, int b) > { > this.removeAllViewsInLayout(); > > // fetch only the visible views > for(int i = 0; i < vcount; i++) > { > layeredviews[i] = allviews[vfirst+i]; > } > > // sort them in drawing order > Arrays.sort(layeredviews, new ViewComparator()); > > // add them back as children in the right order > for(int i = 0; i < vcount; i++) > { > this.addViewInLayout(layeredviews[i], i, > this.generateDefaultLayoutParams()); > } > } > > @Override > public void setAdapter(Adapter value) { > adapter = value; > allviews = new View[adapter.getCount()]; > } > > // more blah omitted > } > > Here is relevant stuff from the adapter used to inflate the list > items: > > public class MagicAdapter extends BaseAdapter > { > // blah adapter stuff omitted. > > public View getView(int position, View convertView, ViewGroup > parent) > { > View v = inflater.inflate(R.layout.magicitem, null); > return v; > } > > } > > Here is the magicitem XML that is inflated as the child views that the > MagicList is handling. Note that I NEVER see the image view. I only > see the drawable background for the FrameLayout. > > <?xml version="1.0" encoding="UTF-8"?> > <FrameLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:background="@drawable/tab"> > <ImageView > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:src="@drawable/icon" > /> > </FrameLayout> > > > > > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

