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>




--~--~---------~--~----~------------~-------~--~----~
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