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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:24:35+00:00 2026-05-21T03:24:35+00:00

Im currently trying to develop a little game where i want to use a

  • 0

Im currently trying to develop a little game where i want to use a class that extends SurfaceView and have it to draw in i thread (similar to LunarLander). However when i would like to change contentview to the one from xml, the one im not drawing in i was trying to call a method from my surfaceview class that is in activity class that will change contentview by setContentView, i get an RuntimeException:

"Can't create handler inside thread that has not called Looper.prepare()"

It’s probably just because im somehow new to android and java development but i don’t understand why it will work when the method is a static method but not otherwise?

(method in my Start class that extends activity)

    public void simulationDone()
{
  .....
}

(trying to access it)

new Start().simulationDone();
  • 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-21T03:24:36+00:00Added an answer on May 21, 2026 at 3:24 am

    A couple of problems:

    First, you shouldn’t call setContentView multiple times.

    Second, your surface view will need a reference to your activity. I tend to define listeners on my views that need to communicate back with an activity. In a custom SurfaceView called MySurfaceView:

    public static interface Listener {
        public void simulationDone();
    }
    
    private Listener listener;
    
    public void setListener(Listener listener) {
        this.listener = listener;
    }
    

    Then have your activity implement MySurfaceView.Listener and call mySurfaceView.setListener(this) when you create your surface view.

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

Sidebar

Related Questions

I am currently trying to use Eclipse to develop some code that I've been
I'm currently trying to develop a site which queries text information. I already have
I am currently trying to develop a small simulation program in xna that takes
I'm trying to develop a webapp with Restlet and I have a little problem
I'm trying to develop a cross platform application. Currently I have set up following
I'm trying to develop an application that will use getImageData in javascript in Firefox
I am currently trying to develop a website where I need to have 2
I'm currently trying to develop a program which stores lots of data, similar to
currently I am trying to develop a game trainer in delphi. I've got the
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 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.