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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:27:08+00:00 2026-05-28T14:27:08+00:00

I have written an app that basically shows a bouncing ball on the screen.

  • 0

I have written an app that basically shows a bouncing ball on the screen. I want to add a SeekBar that increases the velocity of the ball when I change its value. I made functions in my Ball class to get and set the x and y velocities.

package perseus.gfx.test;
import everything;
public class GfxActivity extends Activity implements OnSeekBarChangeListener {

ViewGroup.LayoutParams vg = new ViewGroup.LayoutParams(-1, -1);
double velx, vely;
double x, y;
double finx, finy;
SeekBar velo;
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);                     
    Ball ball = new Ball(this);
    setContentView(R.layout.main);
    addContentView(ball, vg);        
    tv = (TextView)findViewById(R.id.test);
    velo = (SeekBar)findViewById(R.id.vel);
    velo.setOnSeekBarChangeListener(this);   


    x = ball.getSpeedX();
    y = ball.getSpeedY();
    ball.setSpeedX(finx);
    ball.setSpeedY(finy);
}
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {       


    finx = x + arg1;
    finy = y +arg1;
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
    //nothing
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
    //nothing
}
}

The problem is, (I think), only the local values of fin1 and fin2 are affected, and so the ball doesn’t move at all.
How do I pass the values of fin1 and fin2 back to onCreate()?

  • 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-28T14:27:09+00:00Added an answer on May 28, 2026 at 2:27 pm

    You don’t need to pass them back to onCreate (not really possible, anyhow), you should just need to set the ball’s speed again at the end of onProgresschanged()

    @Override
    public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {       
    
      finx = x + arg1;
      finy = y +arg1;
    
      ball.setSpeedX(finx);
      ball.setSpeedY(finy);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Django app that makes use of Python threading to create
I have written an iPhone app that uses the iPhone's relative GPS location. I
I have written a C# app that runs constantly in a loop and several
I have written a small app that puts my bluetooth in discoverable mode for
I have written a small chat app that uses mysql + php to facilitate
I am learning flex and have written a little app with a TextArea that
I have an app written in C# that lies on a network share. When
I have an app that I've written in C#/WinForms ( my little app ).
We have an app that needs to access network resources. It's written in VB.Net.
JI have written a .NET C# Windows Form app in Visual Studio 2008 that

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.