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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:16:38+00:00 2026-05-31T08:16:38+00:00

First, I am trying to create SeekBar with a change listener. I hope I

  • 0

First, I am trying to create SeekBar with a change listener. I hope I am doing this correctly. Below, red is giving me a null exception. I believe that is because my list is one xml and my seekbar/textview layout is another xml. Is that the case? How would I go about grabbing it?

seekbars.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBarLayout"
>
     <TextView
       android:gravity="center_horizontal"
       android:background="#aa0000"
       android:layout_width="wrap_content"
       android:layout_height="0dp"
       android:layout_weight="1"
       android:id="@+id/seekBarLabel"/> 

      <TextView
       android:gravity="center_horizontal"
       android:background="#aa0000"
       android:layout_width="wrap_content"
       android:layout_height="0dp"
       android:layout_weight="1"
       android:id="@+id/seekBarValue"/>


     <SeekBar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:id="@+id/seekBarID"/>

</LinearLayout>

seekbarlist.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ListView

        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </ListView>


</LinearLayout>

android code

package thisPackage.Tabs;



public class ColorsActivity extends ListActivity implements SeekBar.OnSeekBarChangeListener {
/** Called when the activity is first created. */

//Array Adapter that will hold our ArrayList and display the items on the ListView
SeekBarAdaptor seekBarAdaptor;

//List that will  host our items and allow us to modify that array adapter
ArrayList<SeekBar> seekBarArrayList=null;
TextView myValueText;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.seekbarlist);

    //Initialize ListView        
    ListView lstTest= getListView();

     //Initialize our ArrayList
    seekBarArrayList = new ArrayList<SeekBar>();

    //Initialize our array adapter 
    seekBarAdaptor = new SeekBarAdaptor(ColorsActivity.this, R.layout.seekbars,seekBarArrayList);
    //setContentView(R.layout.seekbars);
    SeekBar red = (SeekBar)findViewById(R.id.seekBarID);
    red.setOnSeekBarChangeListener(this);
   // SeekBar blue = new SeekBar(this);

    //Set the above adapter as the adapter of choice for our list
    lstTest.setAdapter(seekBarAdaptor);

    seekBarArrayList.add(red);
    //seekBarArrayList.add(blue);
}
 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
     //myLayout = (LinearLayout)seekBar.findViewById(R.id.seekBarLayout);
     myValueText = (TextView)findViewById(R.id.seekBarValue);  
     myValueText.setText("hello");
    //myValueText.setText("text");
 }
 public void onStopTrackingTouch(SeekBar seekBar){

 }
 public void onStartTrackingTouch (SeekBar seekBar){
 }

}

logcat

03-15 00:01:52.020: D/AndroidRuntime(345): Shutting down VM

03-15 00:01:52.020: W/dalvikvm(345): threadid=1: thread exiting with uncaught exception (group=0x40015560)

03-15 00:01:52.040: E/AndroidRuntime(345): FATAL EXCEPTION: main

03-15 00:01:52.040: E/AndroidRuntime(345): java.lang.RuntimeException: Unable to start activity ComponentInfo{thisPackage.Tabs/thisPackage.Tabs.ColorsActivity}: java.lang.NullPointerException

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.widget.TabHost.setCurrentTab(TabHost.java:326)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.view.View.performClick(View.java:2485)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.view.View$PerformClick.run(View.java:9080)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.os.Handler.handleCallback(Handler.java:587)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.os.Handler.dispatchMessage(Handler.java:92)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.os.Looper.loop(Looper.java:123)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.ActivityThread.main(ActivityThread.java:3683)

03-15 00:01:52.040: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method)

03-15 00:01:52.040: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507)

03-15 00:01:52.040: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

03-15 00:01:52.040: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

03-15 00:01:52.040: E/AndroidRuntime(345): at dalvik.system.NativeStart.main(Native Method)

03-15 00:01:52.040: E/AndroidRuntime(345): Caused by: java.lang.NullPointerException

03-15 00:01:52.040: E/AndroidRuntime(345): at thisPackage.Tabs.ColorsActivity.onCreate(ColorsActivity.java:52)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

03-15 00:01:52.040: E/AndroidRuntime(345): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

03-15 00:01:52.040: E/AndroidRuntime(345): … 18 more

  • 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-31T08:16:39+00:00Added an answer on May 31, 2026 at 8:16 am

    Is R.id.seekBarID refers to something in R.layout.seekbarlist? If not, then

    SeekBar red = (SeekBar)findViewById(R.id.seekBarID);
    

    will returns null as it cannot find the specified view, it would be helpful if you can post the 2 layout files as well.

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

Sidebar

Related Questions

I'm trying to create a simple threading procedure (granted this is my first attempt
I am trying to create a Python dictionary from a stored list. This first
Sorry this is my first time trying to create a plugin, so I might
This is my first time trying to create an udf for mysql. The docs
This is my first stab at trying to create a JQuery plugin, so I
Trying to create the first project. First got the below error when I ran,
I am trying to create input text like below Image : First I used
This is my first plugin trying to create using the example provided here .
I'm trying to create my first app with AngularJS. It looks neat, but there's
I am trying to create my first custom Print Dialog in C#. I found

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.