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

  • Home
  • SEARCH
  • 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 6902339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:47:09+00:00 2026-05-27T07:47:09+00:00

Hi I am new to android programming. Here my problem is… I designed 2

  • 0

Hi I am new to android programming.
Here my problem is…
I designed 2 layouts.

1) R.layout.main: it consists one TextField,one EditText and one Button

2) R.layout.window: it holds 5 buttons

here at first,R.layout.main is displayed.By default R.layout.main is calling so when i press the button of that main layout it needs to forward to r.layout.window.
Forwarding process is ok..

BUT WHEN I MAKE CALL LIKE
BUTTON button=(Button)findViewById(R.id.b1);// b1 is at R.layout.window

i am getting an exception.. SO CAN I KNOW WHICH METHOD WILL BE CALLED WHEN setContentView() IS CALLED and FROM ONCREATE(),IS IT POSSIBLE TO CALL MULTIPLE LAYOUTS R.id.namess..

waiting for reply

  • 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-27T07:47:10+00:00Added an answer on May 27, 2026 at 7:47 am
    public class UI extends Activity {
        LayoutInflater factory 
        View layout1;
        View layout2;    
    public void onCreate(Bundle bundle){
     .....
     .....
    
     factory =getLayoutInflater();
     layout1 =  factory.inflate(R.layout.main, null);
     layout2 =  factory.inflate(R.layout.window, null);
    .....
    ..... 
       }
    }
    
    
    
    //access R.id.b1 in R.layout.window;
    

    try this

    Button button=(Button)layout2.findViewById(R.id.b1);
    

    if you set the content view to R.layout.main like this setContentView(R.layout.main); then
    you can access widgets in the R.layout.main by findViewById() only like this

    Button b = (Button)findViewById(R.id.button1);
    

    where R.id.button1 inside R.layout.main then when you finish with R.layout.main set the content view of window layout and then access the widgets inside it

    setContentView(R.layout.window);
    
    //now you can access elements in window layout using findViewById
    Button b2  =(Button)findViewById(R.id.button2); 
    

    hope you understand

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

Sidebar

Related Questions

I'm abit new to programming Android App's, however I have come across a problem,
I think it's kinda easy one but still I'm new to android programming so
I have an Activity with two layouts, both implemented in R.layout.main. The first one
I'm new to Android programming and I am making a game. My problem is
Am very new to Android programming, so sorry if this is a simple problem.
Hi I am new to android Programming and NDK.Yet i am not clear with
I'm very new to Android programming, so this is probably something pretty basic. I
I'm new to Android programming. I've seen different phones with different screen resolutions that
I'm really new in Android programming, so I have a simple question getting a
[I'm quite new with Android programming so please excuse me for my nooby questions]

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.