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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:30:12+00:00 2026-06-07T11:30:12+00:00

i got a problem with setContentView which throws me a null pointer. In my

  • 0

i got a problem with setContentView which throws me a null pointer.

In my mainFrame i got a small SurfaceView which takes about 50% of the screen.
I wanted to implement a method which makes that SurfaceView go Full Screen if you long clicked it. I did it like this:

final FrameLayout frame = (FrameLayout) findViewById(R.id.frame_layout);
frame.setOnLongClickListener(new OnLongClickListener() {
    boolean clicked = false;
    @Override
    public boolean onLongClick(View v) {
        if (clicked){
            clicked = false;
            (MyActivity.this).setContentView(R.layout.main);    
        } else {
            clicked = true;
            (MyActivity.this).setContentView(R.layout.fullScreen);
        }

        return true;
    }
});

Can someone help me how to fix this problem?

Greetings

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
android:orientation="vertical"
android:weightSum="1" 
android:background="@drawable/background_new" >

<TextView

    android:text="@string/measures"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/text_measures"
    android:textColor="#ff444444"
    android:layout_marginTop="30dp"
    android:layout_marginLeft="10dp"
    />

<ImageButton
android:contentDescription="@string/desc_edge"
android:layout_toRightOf="@id/text_measures"
android:id="@+id/edges_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/edges_black"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="30dp"
android:onClick="edge_handler"
android:background="@null"              
 />

<FrameLayout
    android:background="@xml/border"
    android:id="@+id/camera_preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="35dp"
    android:layout_marginRight="200dp"
    android:layout_marginTop="80dp"
    android:layout_below="@id/text_measures"        
     >
   </RelativeLayout>

I know it looks like a FrameLayout but dont get fooled it was done by someone else and it is actually a SurfaceView.

  • 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-07T11:30:13+00:00Added an answer on June 7, 2026 at 11:30 am

    Just change the layout parameters of the SurfaceView onLong click of frame. No need to setContentView again.

      LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    
      surfaceView.setLayoutParams(lp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to ask about strcpy. I got problem here. Here is my code:
Well, I got problem here with opengl ES stuff (just started to learn about
i got the following problem: I am developing an app which requires the zxing-QR-Code
I've got a problem which makes me crazy because it looks like a simple
i got a small problem with interrupts. in my android login activity, i start
I'm a beginner. I got a problem. This is an example about canvas on
i got problem with my code and hopefully someone able to figure it out.
I got problem with sending data in Android using httpPost. I found some example,
I've got problem with DirectX in C#. I want to draw some lines. Firstly
I've got problem for my application. I want to start connectbot from my application

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.