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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:16:34+00:00 2026-06-05T04:16:34+00:00

Once I set the contentView to a layout, how can I manage the UI

  • 0

Once I set the contentView to a layout, how can I manage the UI via java? Also, if I start a new activity, do I reset the contentView?

  • 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-05T04:16:37+00:00Added an answer on June 5, 2026 at 4:16 am

    ContentView will only be in one activity.

    Assuming you are in something that extends Activity all you have to do, after setting content view, is access your views. Say you have a button in your layout:

    Button homeButton = (Button) findViewById(R.id.homeButton);
    homeButton.setText(); homeButton.setOnClickListener() etc
    

    If you’re in a dialog, or need to access certain views in specific circumstances, or you’re in an intent and need to access stuff in your main activity’s layout:

    Button secondButton = (Button) getActivity().findViewById(R.id.secondButton);
    //other methods on the button
    

    EDITS–

    Well images, you just add an ImageView into the layout:

    <ImageView android:id="@+id/logoImageView"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:src="@drawable/logo" android:contentDescription="@string/app_name" 
            android:layout_gravity="center_horizontal"/>
    

    You don’t need to do anything with code specifically, it should just show up.

    Buttons and other views can also be added via XML. You can add things programmatically as well, though it’s not as common.

    If I remember correctly, the constructor to create a button in Java that’s not in your XML file, it would be Button aNewButton = new Button(getApplicationContext());
    aNewButton.setText("whatever");

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

Sidebar

Related Questions

Does this smell? I have a few properties you can only set once. They
I have an array of checkboxes that I edit at once to set up
Here i got a problem in my script, Once we set one radio button
Once you have your first set of requirements and design done where do you
Once the structure of a repository is set up, i.e. trunk, branches, tags, is
I used once a very nice emacs function that set all my windows (emacs
I need a set of tasks that need to be executed exactly once for
My team has a situation where an SNMP SET will fail once every two
I have a ComboBox control with the DropDownStyle properties set to DropDownList . Once
UPDATE maybe changing the Bitmap size in the new Activity may fix the problem

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.