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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:00:29+00:00 2026-06-18T01:00:29+00:00

I had done a glSurfaceView embedded inside a layout using android, and there are

  • 0

I had done a glSurfaceView embedded inside a layout using android, and there are some buttons on the leftside of glSurfaceView. By clicking that button a new glSurfaceView should be created on the previous one.

How could I do that? As in this com.example.activity.MyGlSurfaceView is always constant, how can I make it dynamically change it?

 <Linearlayout .....>

  <include android:id="@+id/title_btn"
     android:layout_width="0dp"
     android:layout_height="match_parent"
     android:layout_weight="1"
    layout="@layout/option_button"/>

   <com.example.activity.MyGlSurfaceView
         android:id="@+id/gl_surface_view"
   android:layout_width="0dp"
        android:layout_height="wrap_content" 
   android:layout_weight="8"/> 
       </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-06-18T01:00:30+00:00Added an answer on June 18, 2026 at 1:00 am

    hope it could be the answer for your question

    MyGlSurfaceView sv = (MyGlSurfaceView)findViewById(R.id.gl_surface_view);
    
    yourButton.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            sv = new MySurfaceView(yourContext);
        }
    });
    

    this is my first answer XD

    Added:

    public class MainActivity extends Activity{
    
        MyGLSurfaceView myGl;
        Button button;
        Context context;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            context= this;
            setContentView(R.layout.main_activity);
            myGl = (MyGLSurfaceView)findViewById(R.id.main_gl);
            button = (Button)findViewById(R.id.main_button);
            button.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    myGl = new MyGLSurfaceView(context);
                }
            });
        }
    }
    
    
    
    public class MyGLSurfaceView extends GLSurfaceView {
    
        public MyGLSurfaceView(Context context) {
            super(context);
            this.setRenderer(new MyRenderer());
        }
    
        public MyGLSurfaceView(Context context, AttributeSet attrs) {
            super(context, attrs);
            this.setRenderer(new MyRenderer());
        }   
        static class MyRenderer implements GLSurfaceView.Renderer{
    
            public void onSurfaceChanged(GL10 gl, int w, int h) {
                gl.glViewport(0, 0, w, h);
            }
    
            public void onDrawFrame(GL10 gl) {
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
            }
    
            @Override
            public void onSurfaceCreated(GL10 gl, EGLConfig config) {
                // TODO Auto-generated method stub          
            }
    
    
        }
    }
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <Button
            android:id="@+id/main_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />
    
        <com.renderer.test.MyGLSurfaceView
            android:id="@+id/main_gl"
            android:layout_width="300dp"
            android:layout_height="200dp" />
    
    </LinearLayout>
    

    I am not sure this would suit for your case but it doesn’t make error on my phone.

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

Sidebar

Related Questions

In an interview today I mentioned that I had done some jsf work in
I had done automation testing in my android application, I used robotium framework. Still
I am developing an small application in a android. Before this i had done
I want to have sample application on phoneGap for iphone. i had done some
I am using 64-bit MongoDB and I had done testing with 64-bit MongoDB. The
i want to work in RHO mobiles i had done some r&d and cam
I'm re-writing an Asp.Net project that a colleague had done a prototype version of.
I had done the HTML5 native video playing with Android (Samsung Galaxy pop gts5570)
I had done the registration using ASP.NET CreateUserWizard Control . In here I want
Problem is we had done some changes and check in the code and build

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.