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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:45:27+00:00 2026-05-22T21:45:27+00:00

Here is my main: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LinearLayout layout

  • 0

Here is my main:

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    LinearLayout layout = (LinearLayout) findViewById(R.id.mainView);
    TextView text=  (TextView) findViewById(R.id.text);
    text.setText("This is a Test!");

    firstCircle first = new firstCircle(this);
    secondCircle second = new secondCircle(this);
    layout.addView(first);
    layout.addView(second);

}

Here is my firstCircleClass:

public class firstCircle extends SurfaceView implements SurfaceHolder.Callback {

private firstThread _firstThread;
private secondThread _secondThread;
private SurfaceHolder surfaceHolder;


public firstCircle (Context context, AttributeSet attrs){
    super(context,attrs);
    getHolder().addCallback(this);
    setFocusable(true);
    _firstThread= new firstThread(getHolder(),this);

}

public firstCircle (Context context){
    super(context);
    getHolder().addCallback(this);
    setFocusable(true);
    _firstThread= new firstThread(getHolder(),this);

}

@Override
public void onDraw(Canvas c){

    String tag="My Activity";
    Paint paint = new Paint();
    paint.setColor(Color.BLUE);

      c.drawCircle(100,100,100,paint);

}

@Override
public void surfaceCreated(SurfaceHolder holder){
    _firstThread.setRunning(true);
    _firstThread.start();
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){

}

@Override
public void surfaceDestroyed(SurfaceHolder holder){
    boolean retry = true;
    _firstThread.setRunning(false);
    while (retry){
        try{
            _firstThread.join();
            retry = false;
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}




}

I have a secondCircle class that is the exact same as above with the name changed and the color of the circle being Red.

Here is my firstThread class:

public class firstThread extends Thread {

private SurfaceHolder _surfaceHolder;
private firstClass _firstClass;
private boolean _run = false;

public firstThread (SurfaceHolder surfaceHolder, firstClass first){
    _surfaceHolder = surfaceHolder;
    _firstClass= first;

}


public void setRunning (boolean run){
    _run = run;
}

@Override
public void run(){

    while(_run){
        Canvas c=null;
        try{
            c = _surfaceHolder.lockCanvas(null);
            synchronized(_surfaceHolder){
                    _firstThread.onDraw(c);
            }


        } finally {
        }
            if (c!=null){
                _surfaceHolder.unlockCanvasAndPost(c);
            }
        }
    }

}

I have a secondThread class that is the same as above with a different name and that calls secondCircle’s onDraw().

When i run this program it only shows the blue circle and not the red circle. Why is this?

  • 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-22T21:45:27+00:00Added an answer on May 22, 2026 at 9:45 pm

    when you add the views, add them with layout parameters. Its possible the 1st view is filling the parent, leaving no space for the second view.

    you could do something like

    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layout.addView(first,p);
        layout.addView(second,p);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code: public class MenuTabActivity extends TabActivity implements OnTabChangeListener{ @Override protected void onCreate(Bundle
Here is a quick test program: public static void main( String[] args ) {
Here's the basic idea: There is a java window (main) that opens another java
Okay here's the program I have typed up(stdio.h is included also): /* function main
In my main page (call it index.aspx ) I call <%Html.RenderPartial(_PowerSearch, ViewData.Model);%> Here the
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote

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.