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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:06:32+00:00 2026-05-29T06:06:32+00:00

I have an android program that I am making with 4 seekbars, and 4

  • 0

I have an android program that I am making with 4 seekbars, and 4 textviews to accompany each seekbar. Right now, I am trying to make each textview’s contents equal to the integer progress of the seekbars. This is my code as it stands, and I have tried many ways to properly implement the OnSeekBarChangeListener, but LogCat still shows that it is null when sb1-sb4 sets their OnSeekBarChangeListener to OnSeekBarProgress. Please help me identify my problem 🙁

public class TippopotamusActivity extends Activity {
    SeekBar sb1;
    SeekBar sb2;
    SeekBar sb3;
    SeekBar sb4;
    TextView tv1;
    TextView tv2;
    TextView tv3;
    TextView tv4;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    tv1 = (TextView) findViewById(R.id.textView1);
    tv2 = (TextView) findViewById(R.id.textView2);
    tv3 = (TextView) findViewById(R.id.textView3);
    tv4 = (TextView) findViewById(R.id.textView4);

    sb1 = (SeekBar) findViewById(R.id.seekBar1);
    sb2 = (SeekBar) findViewById(R.id.seekBar2);
    sb3 = (SeekBar) findViewById(R.id.seekBar3);
    sb4 = (SeekBar) findViewById(R.id.seekBar4);

    sb1.setOnSeekBarChangeListener(OnSeekBarProgress);
    sb2.setOnSeekBarChangeListener(OnSeekBarProgress);
    sb3.setOnSeekBarChangeListener(OnSeekBarProgress);
    sb4.setOnSeekBarChangeListener(OnSeekBarProgress);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

OnSeekBarChangeListener OnSeekBarProgress =
        new OnSeekBarChangeListener() {

        public void onProgressChanged(SeekBar s, int progress, boolean touch){
            if(s.getId() == R.id.seekBar1)
            {
                tv1.setText(progress);
            }
            else if(s.getId() == R.id.seekBar2)
            {
                tv2.setText(progress);
            }
            else if(s.getId() == R.id.seekBar3)
            {
                tv3.setText(progress);
            }
            else
            {
                tv4.setText(progress);
            }
        }

        public void onStartTrackingTouch(SeekBar s){

        }

        public void onStopTrackingTouch(SeekBar s){

        }
        };
  • 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-29T06:06:33+00:00Added an answer on May 29, 2026 at 6:06 am

    Move your setContentView(R.layout.main); before initializing your variables. Your onCreate method should look like this

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        tv1 = (TextView) findViewById(R.id.textView1);
        tv2 = (TextView) findViewById(R.id.textView2);
        tv3 = (TextView) findViewById(R.id.textView3);
        tv4 = (TextView) findViewById(R.id.textView4);
    
        sb1 = (SeekBar) findViewById(R.id.seekBar1);
        sb2 = (SeekBar) findViewById(R.id.seekBar2);
        sb3 = (SeekBar) findViewById(R.id.seekBar3);
        sb4 = (SeekBar) findViewById(R.id.seekBar4);
    
        sb1.setOnSeekBarChangeListener(OnSeekBarProgress);
        sb2.setOnSeekBarChangeListener(OnSeekBarProgress);
        sb3.setOnSeekBarChangeListener(OnSeekBarProgress);
        sb4.setOnSeekBarChangeListener(OnSeekBarProgress);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to android and i am trying to make a program that outputs
I'm making an android program that retrieves content of a webpage using HttpURLConnection. I'm
I have been working on a Android Web Services program that uses a number
I'm trying to make test-program that opens a website by pushing a button. I
I have a program that I'm writing in Android using Eclipse. It has an
In my Android program, I have some code that downloads a file. This works
Good afternoon. I have been making a small openGL based app for android that
I have implemented an android program that can receive simple messages using the MJSIP,
I'm making an Android program. It's SMS related. I have an HTC and since
So I'm making a program for android that tries to download something from www.wupload.com.

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.