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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:57:13+00:00 2026-05-25T17:57:13+00:00

I have two classes A and B A is main activity class and B

  • 0

I have two classes A and B A is main activity class and B is View class. Now I am calling View by setcontentview. when the view is active and i am drawing on it . I want the activity class is active so how do i do that ?

public class A extends Activity {
    B b;


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.button);
        b = new B(this);

        Button but = (Button) findViewById(R.id.showView);
        but.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                 setContentView(drawView);
                 drawView.requestFocus();
            }
        });

    }
}

public class b extends View  implements OnTouchListener {


    public DrawView(Context context) {
        super(context);
        setFocusable(true);

        mContext = context;
        setFocusableInTouchMode(true);
        this.setBackgroundColor(Color.WHITE);
        this.setOnTouchListener(this);

        paint.setColor(Color.GRAY);
        paint.setAntiAlias(true);




    }
public void onDraw(Canvas canvas) {

        mCanvas = canvas;
draw something 
}


}
  • 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-25T17:57:14+00:00Added an answer on May 25, 2026 at 5:57 pm

    setContentView() replaces the entire view of the Activity. If you want to go back to the old view, call setContentView() again with the old view again. By convention though, this is bad. Generally you only do one view per activity.

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

Sidebar

Related Questions

I have two classes that extend the activity class. Each class has it's own
I have two classes, and want to include a static instance of one class
I have two classes, Foo and Bar, that have constructors like this: class Foo
I have two classes orchestrated by a main class and I would like to
I have two classes : import android.cla; public class CW { public static void
I have two classes, shown below: [Serializable] [XmlInclude(typeof(SomeDerived))] public class SomeBase { public string
I have two classes: Action class, that has a method for executing VBScript files,
I have defined two classes below: public class junk { private BigInteger a =
I have two classes A and B as follows: public class A { private
I have the following two classes: package { import flash.display.Sprite; import flash.events.Event; public class

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.