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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:58:46+00:00 2026-05-26T00:58:46+00:00

I want to cast multiple XML layouts as views. Because of a change request

  • 0

I want to cast multiple XML layouts as views. Because of a change request I need to use a ViewSwitcher. So I have to cast the XML layout to Views before setContentView.

I always get a NullPointerException. I tried:

view = (View) findViewById(R.id.viewgroup_id);

view = (RelativeLayout) findViewById(R.id.viewgroup_id);

view = (View) findViewById(R.layout.xml_layout);

view = (View) getResources().getLayout(R.layout.xml_layout);

  • 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-26T00:58:47+00:00Added an answer on May 26, 2026 at 12:58 am

    Try using LayoutInflater. Use this code inside your activity code-

       LayoutInflater inflater = getLayoutInflater();
       View view = inflater.inflate(R.layout.your_layout, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some pb. I want to cast a List to Collection in java
I have a thrust device_vector . I want to cast it to a raw
I want to overload a cast operator, I have the following piece of code
I have multiple NxM matrices and want to select one of them by a
I want to have a single event listener for multiple events and depending on
I have viewport3D and I want to add multiple 3d objects defined in xaml
I want to cast an int that's passed to the template through the url,
Hi i want to cast the Parent object to Child object in C# public
I want to reinterpret cast a function pointer into a void* variable. The type
Basically i want to do this. aa causes a bad cast exception. NOTE: o

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.