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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:40:58+00:00 2026-05-24T06:40:58+00:00

In the main class of my project, I have public class MyClass extends Activity{

  • 0

In the main class of my project, I have

public class MyClass extends Activity{
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        mySurfaceView = new MySurfaceView(this);
        setContentView(mySurfaceView); 
        ...
    }

    class MySurfaceView extends SurfaceView implements Runnable{
       ...
    }
}

I want to add buttons and wheels to this program, which I have in a separate mini-program right now with a main.xml file. I know that to access that, I have to have the line setContentView(R.layout.main), but then, I lose access to my SurfaceView. How do I make it so that I have both? I saw something online about adding a few lines with a FrameLayout but I can’t figure out where, and I’ve tried sticking it in various places in my main.xml but it just causes my entire program to break..

Currently my main.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
 <Button android:id="@+id/selectButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Select Time Interval"
android:onClick="selfDestruct"
/>
<Button android:id="@+id/finishButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Done"
android:visibility="gone"
android:onClick="selfDestruct"
/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="top|left"
    android:paddingLeft="12dp"
    android:paddingRight="12dp"
    >
    <kankan.wheel.widget.WheelView android:id="@+id/startHour"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="43dp"/>
    <kankan.wheel.widget.WheelView android:id="@+id/startMins"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/startAmpm"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >
        <TextView android:id="@+id/theWordTo"
            android:visibility="gone"
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="   to   "/>
        </LinearLayout>

        <kankan.wheel.widget.WheelView android:id="@+id/endHour"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="43dp"
        />
    <kankan.wheel.widget.WheelView android:id="@+id/endMins"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
        <kankan.wheel.widget.WheelView android:id="@+id/endAmpm"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
</LinearLayout>

</LinearLayout>
  • 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-24T06:40:59+00:00Added an answer on May 24, 2026 at 6:40 am

    I think you want to use FrameLayout. Change your main.xml to look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <kankan.current.app.MyClass.MySurfaceView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/surfaceView" />
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
     <Button android:id="@+id/selectButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="Select Time Interval"
    android:onClick="selfDestruct"
    />
    <Button android:id="@+id/finishButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="Done"
    android:visibility="gone"
    android:onClick="selfDestruct"
    />
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="top|left"
        android:paddingLeft="12dp"
        android:paddingRight="12dp"
        >
        <kankan.wheel.widget.WheelView android:id="@+id/startHour"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="43dp"/>
        <kankan.wheel.widget.WheelView android:id="@+id/startMins"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
            <kankan.wheel.widget.WheelView android:id="@+id/startAmpm"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
    
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent" >
            <TextView android:id="@+id/theWordTo"
                android:visibility="gone"
                android:layout_width="wrap_content" 
                android:layout_height="fill_parent"
                android:gravity="center"
                android:text="   to   "/>
            </LinearLayout>
    
            <kankan.wheel.widget.WheelView android:id="@+id/endHour"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="43dp"
            />
        <kankan.wheel.widget.WheelView android:id="@+id/endMins"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
            <kankan.wheel.widget.WheelView android:id="@+id/endAmpm"
            android:visibility="gone"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
    </LinearLayout>
    
    </LinearLayout>
    
    </FrameLayout>
    

    Then in in the activity:

    public class MyClass extends Activity{
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main); 
            mySurfaceView = (MySurfaceView) findViewById(R.id.surfaceView);
        }
    
        class MySurfaceView extends SurfaceView implements Runnable{
           ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created simple project with class Main and public static void main and
Let's say that my project has a main class. I'd love to have public
so I have a project that only has one class Main: public class Main{
i have any div for show details of project ( class main ). now
I have a main class and two extended classes: class Main { public $foo;
I have a project in NetBeans where two different classes have public static void
I have successfully implemented actionsherlock in my project.so here is my code: public class
I have few classes in my project.the main class should me SMSMain.But when i
I need to debug a class library project that is provided to the main
I am writing a custom Control class in C# for my main project. There're

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.