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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:32:52+00:00 2026-06-12T09:32:52+00:00

I have an android application showing coverflow animation.I want to use view extending surfaceview

  • 0

I have an android application showing coverflow animation.I want to use view extending surfaceview inside coverflow.But this code did not show anything.

public class CoverFlowView extends SurfaceView implements Callback {

    public CoverFlowView(Context context) {
        super(context);
    }

    public CoverFlowView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CoverFlowView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public void surfaceChanged(SurfaceHolder holder, int format, int width,
            int height) {

    }


    public void surfaceCreated(SurfaceHolder holder) {


         MyThread  myThread = new MyThread(holder);
         myThread.setFlag(true);
         myThread.start();
    }


    public void surfaceDestroyed(SurfaceHolder holder) {

    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint borderPaint = new Paint();
        borderPaint.setARGB(255, 255, 128, 0);
        borderPaint.setStyle(Paint.Style.STROKE);
        borderPaint.setStrokeWidth(4);
        canvas.drawRect(0, 0, getWidth() - 1, getHeight() - 1, borderPaint);
    }

    class MyThread extends Thread {
        boolean flag;
        SurfaceHolder myHolder;
        public MyThread(SurfaceHolder holder) {
            myHolder = holder;
        }

        public void setFlag(boolean myFlag) {
            flag = myFlag;
        }

        public void run() {
            Canvas canvas = null;
            while (flag) {
                try {
                    canvas = myHolder.lockCanvas();
                    synchronized (myHolder) {
                          invalidate();
                        }

                } finally {
                    if (canvas != null) {
                        myHolder.unlockCanvasAndPost(canvas);
                    }
                }
            }
        }
    }

}

What is the problem here?I am new with Surfaceview.

Thanks in advance.

  • 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-12T09:32:53+00:00Added an answer on June 12, 2026 at 9:32 am

    Rewrite your code like this , then it will work fine, i have checked it

    public class CoverFlowView extends SurfaceView implements SurfaceHolder.Callback {
    

    then change your constructor to

    public CoverFlowView(Context context) {
        super(context);
        getHolder().addCallback(this);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that showing maps using OSMDroid. I want to get
I have declared a simple ProgressDialog in my android application but it isn't showing
I have an android application and web-server working together. Now I want user log
I have an android application. There are a lot of buttons in it but
I have an Android application, backed by an API. To this API users can
I have an Android application with a Spinner and want to fill it dynamically
I have an android application and while switching between two activities I want to
I have develop android application using Android SDK, Eclipse IDE.In that some times showing
I have created a Android application using Google Maps. Now I want to check
Hello i have created a sample application in android using eclipse IDE my code

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.