Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:45:54+00:00 2026-06-07T06:45:54+00:00

So I have written a ‘multi-sliding drawer’ widget, which works like Slidingdrawer except it

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:45:56+00:00Added an answer on June 7, 2026 at 6:45 am

    You can define your widget to have parameters (say, handles andcontents) that each takes a reference to an array. You can define the arrays using the standard notation:

    res/values/arrays.xml

    <array name="my_widget_layouts">
        <item>@layout/contentLayout1</item>
        <item>@layout/contentLayout2</item>
        . . .
    </array>
    
    <array name="my_widget_buttons">
        <item>@+id/slideHandleButton1</item>
        <item>@+id/slideHandleButton2</item>
        . . .
    </array>
    

    inside some layout:

    <com.example.MyWidget
        ns:contents="@array/my_widget_layouts"
        ns:handles="@array/my_widget/buttons"
        . . .
        />
    

    Then in the Java code when you construct your widget:

    MyWidget(Context context, AttributeSet attrs) {
        Resources res = getResources();
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyWidget);
        // Get the ID of the array containing the content layout IDs for this widget
        int contentsId = a.getResourceId(R.styleable.MyWidget_contents, 0);
        if (contentsId > 0) {
            // array of layouts specified
            TypedArray ta = res.obtainTypedArray(contentsId);
            int n = ca.length();
            mContentLayoutIds = new int[n];
            for (int i = 0; i < n; ++i) {
                mContentLayoutIds[i] = ta.getResourceId(i, 0);
                // error check: should never be 0
            }
            ta.recycle();
        }
        // similar code to retrieve the button IDs
        if (mContentLayoutIds.length != mHandleIds.length) {
            // content layout and button arrays not same length: throw an exception
        }
        . . .
        a.recycle();
        . . .
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
I have written a bash script which installs a number of packages, however for
I have written this code in JavaScript and works perfectly fine when I include
I have written a raw binary image file into a buffer which is an
have written a stochastic simulation in Java, which loads data from a few CSV
I have written a Java program which I package and run from a JAR
I have written a PhaseListener in which I am checking for the Validations phase.
I have written a web-service (in Java) which produces as a result a (rather
I have written a simple WCF web service in C# which returns records from
I have written a function for browser compatibility. When I pass objTR.cells[0] it works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.