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 7573631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:13:52+00:00 2026-05-30T16:13:52+00:00

It looks like a kind of wrong approach, but I’d still ask. The task

  • 0

It looks like a kind of wrong approach, but I’d still ask.

The task is, you have a layout xml that describes a composite widget (like Button + TextView). You’d like to make it re-usable, so you build a class like MyTextViewButtonWidget – it will expose its button text accessors and it will also do the same for text view:

public class MyTextViewButtonWidget extends LinearLayout {
    ...
    void setButtonText(String text) { ... }
    String getButtonText() { ... }
    void setTextViewText(String text) { ... }
    String getTextViewText() { ... }
    ...
}

Layout definition looks like this:

<LinearLayout ..........>
   ....button and text label here...
</LinearLayout>

The question is – how would you load this layout so that its root LinearLayout would be the LinearLayout part of MyTextViewButtonWidget?

Tried defining MyTextViewButtonWidget‘s ctor like this:

{
    inflate(getContext(), R.layout.reusable_widget_layout, this);
}

But this loads reusable_widget_layout as a child to MyTextViewButtonWidget (that’s not what I need).

Generally, the problem is:

  • You need to create a composite widget
  • You’d like to be able to define its layout with xml markup
  • You’d like it to load root’s child widgets defined in xml as its child widgets (INSTEAD OF: load the whole hierarchy from xml as a single child of your reusable widget)
  • 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-05-30T16:13:53+00:00Added an answer on May 30, 2026 at 4:13 pm

    Replace:

    <LinearLayout ..........>
       ....button and text label here...
    </LinearLayout>
    

    with:

    <merge ..........>
       ....button and text label here...
    </merge>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that looks kind of like this: <div> <div class=contact> <h1>Person's
Let's say that you have a Model that looks kind of like this: public
Part of the XML looks like this: <ipcEntry kind=1 symbol=A01B0013080000 ipcLevel=A entryType=K lang=EN nocore=yes>
I have to develop an iPad TV guide that looks like What's On TV
In my program I have currently a piece of code that looks like this
I am parsing an XML doc that looks something like this: <MyBook> <title>Favorite Poems</title>
Looks like this question has been asked thousand times already, but each person's configuration
Looks like operator new and operator new[] have exactly the same signature: void* operator
Looks like the options are Propel, Doctrine, and ActiveRecord, others?, but I am only
Looks like a dumb question, but I tried the following (where Me is a

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.