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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:36:11+00:00 2026-06-14T16:36:11+00:00

I have a custom component with one RadioGroup that has two RadioButton, ids @+id/radioButton1

  • 0

I have a custom component with one RadioGroup that has two RadioButton, ids @+id/radioButton1 and @+id/radioButton2. On the other hand, there is a TabActivity with five tabs. On each tab, this component is used more than one time.

Here’s the problem, when orientation changes and the activity is recreated, all of the RadioButton is loaded with the same attrs, this includes android:text, android:margin and even the styled attrs that i’ve created. It also happens with all the CheckBox that has the same ids.

I spent some time trying to discover why this was happening and concluded that android is doing that in onRestoreInstanceState. If I comment the line that calls the super method it works fine.

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    // super.onRestoreInstanceState(savedInstanceState);

}

Is this how it’s supposed to be? Or what could one do to cause this?

I’m guessing that it’s not a normal behaviour because when a custom view is created, it inflates the same layout with the same views that has the same ids. So it’s not possible to instantiate a new custom view generating different ids for its child every time. Using the code above or android:configChanges on the manifest seems to be a bad workaround to me. So, any help is appreciated.

  • 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-14T16:36:13+00:00Added an answer on June 14, 2026 at 4:36 pm

    After some time searching for an explanation, I finally found a great one from Romain Guy in the android google group, although it doesn’t mention custom views.

    “It’s ok to use same ids except when you need the views to save their state. The id is
    what identifies views when their state is saved so the toolkit simply
    think that your two views are the same. But that’s true within an
    activity only. “

    “There is no problem using the same id in two different activities. And
    there is no problem using the same id inside the same activity if
    you’re careful about what you’re doing (for instance, if the views
    with the shared ids do not need to save any state.) In your case,
    because the activities are part of a set of tabs, they are actually
    tied to a unique context which means you will run into problems with
    shared ids. “

    Here’s the link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom component, ExportCommandButton, that has two attached properties. This component is
I have an user control named GraphPanel. It has two dependency properties, one custom,
I have custom component that I can place in my layout file (XML) for
I have a custom component, that contains a list of another components. If I
I have a custom component that is vertically longer than the screen height and
We have a custom JSF component that renders some buttons and a select box
I have just built a custom autocomplete component using jquery. My problem is that
I have built a custom view component that displays a timeline of events. The
I have a custom built sign up component that I would like to enhance.
I have this very simple custom component, made out of two Labels : _left

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.