So I have written a ‘multi-sliding drawer’ widget, which works like Slidingdrawer except it allows up to 4 ‘drawers’. However, I would really prefer to make this ‘n-drawers’, but the issue I have is with the parameters in xml. Currently, I am passing in the handles/contents via:
ns:handle1="@+id/slideHandleButton1"
ns:content1="@+id/contentLayout1"
ns:handle2="@+id/slideHandleButton2"
ns:content2="@+id/contentLayout2"
ns:handle3="@+id/slideHandleButton3"
ns:content3="@+id/contentLayout3"
but obviously there is some redundancy here. I originally thought I could just use ‘getChild(i)’ to cycle through the children and add them internally, but my understanding is that the getChild method returns children in visual order, not the order they were added in xml. So what I want to do now is something like:
ns:handles="@id/contentLayout1,@id/contentLayout2,@id/contentLayout13"
which would allow an arbitrary number of drawers. Is this possible? Or is there another good solution to this issue?
You can define your widget to have parameters (say,
handlesandcontents) that each takes a reference to an array. You can define the arrays using the standard notation:res/values/arrays.xml
inside some layout:
Then in the Java code when you construct your widget: