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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:49:43+00:00 2026-06-16T03:49:43+00:00

I have this MainActivity class in Android with multiple SeekBars: package com.simplemathgame; import android.os.Bundle;

  • 0

I have this MainActivity class in Android with multiple SeekBars:

package com.simplemathgame;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class MainActivity extends Activity  implements OnSeekBarChangeListener {
    private TextView numberOfAddDrills = (TextView) findViewById(R.id.add_drills_number);
    private TextView numberOfSubDrills = (TextView) findViewById(R.id.sub_drills_number);
    private TextView numberOfMulDrills = (TextView) findViewById(R.id.mul_drills_number);
    private TextView numberOfDivDrills = (TextView) findViewById(R.id.div_drills_number);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SeekBar addSeekBar = (SeekBar) findViewById(R.id.add_seek_bar);
        SeekBar subSeekBar = (SeekBar) findViewById(R.id.sub_seek_bar);
        SeekBar mulSeekBar = (SeekBar) findViewById(R.id.mul_seek_bar);
        SeekBar divSeekBar = (SeekBar) findViewById(R.id.div_seek_bar);

        addSeekBar.setOnSeekBarChangeListener(this);
        subSeekBar.setOnSeekBarChangeListener(this);
        mulSeekBar.setOnSeekBarChangeListener(this);
        divSeekBar.setOnSeekBarChangeListener(this);
        Log.w("here","2");
    }

    @Override
    public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2){
        Log.w("here","3");
        switch (arg0.getId()) 
        {
        case R.id.add_seek_bar:
            numberOfAddDrills.setText(""+arg1);
            break;
        case R.id.sub_seek_bar:
            numberOfSubDrills.setText(""+arg1);
            break;
        case R.id.mul_seek_bar:
            numberOfMulDrills.setText(""+arg1);
            break;
        case R.id.div_seek_bar:
            numberOfDivDrills.setText(""+arg1);
            break;
        }
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        // TODO Auto-generated method stub

    }   
}

Here is the LogCat:

12-20 08:58:49.402: D/dalvikvm(668): GC_EXTERNAL_ALLOC freed 43K, 53% free 2546K/5379K, external 1917K/2137K, paused 43ms
12-20 08:58:52.563: D/AndroidRuntime(668): Shutting down VM
12-20 08:58:52.563: W/dalvikvm(668): threadid=1: thread exiting with uncaught exception (group=0x40015560)
12-20 08:58:52.582: E/AndroidRuntime(668): FATAL EXCEPTION: main
12-20 08:58:52.582: E/AndroidRuntime(668): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.simplemathgame/com.simplemathgame.MainActivity}: java.lang.NullPointerException
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.os.Looper.loop(Looper.java:123)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread.main(ActivityThread.java:3683)
12-20 08:58:52.582: E/AndroidRuntime(668):  at java.lang.reflect.Method.invokeNative(Native Method)
12-20 08:58:52.582: E/AndroidRuntime(668):  at java.lang.reflect.Method.invoke(Method.java:507)
12-20 08:58:52.582: E/AndroidRuntime(668):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-20 08:58:52.582: E/AndroidRuntime(668):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-20 08:58:52.582: E/AndroidRuntime(668):  at dalvik.system.NativeStart.main(Native Method)
12-20 08:58:52.582: E/AndroidRuntime(668): Caused by: java.lang.NullPointerException
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.Activity.findViewById(Activity.java:1647)
12-20 08:58:52.582: E/AndroidRuntime(668):  at com.simplemathgame.MainActivity.<init>(MainActivity.java:11)
12-20 08:58:52.582: E/AndroidRuntime(668):  at java.lang.Class.newInstanceImpl(Native Method)
12-20 08:58:52.582: E/AndroidRuntime(668):  at java.lang.Class.newInstance(Class.java:1409)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-20 08:58:52.582: E/AndroidRuntime(668):  ... 11 more
12-20 08:58:54.923: I/Process(668): Sending signal. PID: 668 SIG: 9

I don’t know where is this java.lang.RuntimeException. Thanks

  • 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-16T03:49:44+00:00Added an answer on June 16, 2026 at 3:49 am

    You should take a look here, and see what’s null at that point:

    12-20 08:58:52.582: E/AndroidRuntime(668): Caused by: java.lang.NullPointerException
    12-20 08:58:52.582: E/AndroidRuntime(668):  at android.app.Activity.findViewById(Activity.java:1647)
    12-20 08:58:52.582: E/AndroidRuntime(668):  at com.simplemathgame.MainActivity.<init>(MainActivity.java:11)
    

    So line 11 is where the crash is.

    The problem is you cannot call findViewById from there, call them inside the OnCreate method, after the setContentView.

    Hope that helps.

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

Sidebar

Related Questions

I have this code in the main activity: package flash.light.pro; import android.os.Bundle; import android.app.Activity;
solved by Emil thx I have following in my main package com.example.surfacetest; import android.os.Bundle;
I have this code public class MainActivity extends Activity { private static final int
I have this situation where i have to start an activity from my mainActivity.
I have an activity ( MainActivity.java ) in which content view is like this
I have this problem in android. i have a main activity who calls a
I have this Service class: public class BluetoothService extends Service { private static Activity
I have a design of activities like this I have one main activity and
I have a lot of buttons on main activity. Each button run this same
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do

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.