Couldn't get the seekbar by findViewById

by Jeruliu » Sat, 29 May 2010 01:31:23 GMT

Sponsored Links
 I'm building a dialog including seekbar but i can't locate the seekbar
by findViewById, it only returns nullpoint.

My code:
Context mContext = this;
                LayoutInflater inflater = (LayoutInflater)
                View layout = inflater.inflate(R.layout.brightness,

                builder = new AlertDialog.Builder(mContext);
                builder.setPositiveButton("Ok", new
DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int 
whichButton) {
/////////// The seekBar here is a null point however?
                                SeekBar seekBar = (SeekBar) 
                                int progress = seekBar.getProgress();
                                Log.v(TAG, "=====++++ progress is : " + 

And my layouy brightness.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" 
        android:id="@+id/layout_root" android:orientation="vertical"
android:layout_height="fill_parent" android:gravity="center">
        <ImageView android:id="@+id/brightness_level_icon"
        <SeekBar android:id="@+id/seekbar" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:max="255"
                android:progress="125" />

Any hints from your expertshanks.


Couldn't get the seekbar by findViewById

by Mark Murphy » Sat, 29 May 2010 02:09:32 GMT


You are calling findViewById() on your activity. Your activity
presumably does not have a SeekBar named

Try calling layout.findViewById( instead.

Mark Murphy (a Commons Guy)  |  | 

Android App Developer Books: 


Sponsored Links

Couldn't get the seekbar by findViewById

by Jeruliu » Sat, 29 May 2010 11:34:15 GMT

 Wow, thanks Mark, you are absolutely not just a common guy!!!


Other Threads

1. Is Android clock, which is in the destop, a widget or application (Activity)?

As of cupcake, it is a widget.  Before it was just special built-in stuff in
the home app.  There is a blog post about the new widget APIs on the
developer site.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


2. How to get the phone call talking status


    How can i get the status whether the phone call is talking or not



3. java.lang.SecurityException: Permission Denial in inserting an entry to Database

4. InputMethod get activate on non-textview

5. 1.5 SDK Media Question: why doesn't have option for AMR-NB?

6. Where all the OpenGL/FPS games for Android?

7. How do live folders register for change in content?