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. Listen to Virtual Keyboard events when within an EditText

I have confirmed it by making various attempts with this listener, it
will not work for alphabetic inputs from the virtual keyboard on
device. You can use the Tex{*filter*}cher instead which can serve the
purpose if you dont want to specifically catch the onKeyUp() and
onKeyDown() events. It works pretty fine.

You can try adding the tex{*filter*}cher using the
addTextChangeListener(tex{*filter*}cher) on a textView or its subclass

Hope this helps!


2. Display (and position) video on top of other graphical content


I need to display video (using the MediaPlayer API) on top of other
graphical content. I currently do this the following way:

* Create one subclass of SurfaceView, and render graphics to it using
* Create another subclass of SurfaceView, and associate a MediaPlayer
with it using MediaPlayer.setDisplay(holder), where holder is the
SurfaceHolder of the SurfaceView.
* Add both SurfaceViews to my Activity using addContentView.

This basically works; the video is displayed on top of the graphical
content and plays ok. Some problems though:

1) According to Google, multiple SurfaceViews are not supposed to be
used in a window. The fact that it works for me seems to be by chance,
and behaviour could change in future versions of Android.

2) The video is placed in the upper left corner, and I haven't found a
way to position it differently.

Any suggestions on a different approach to implement this, that would
not make use of multiple surface views, and also allow me to position
the video, would be much appreciated.



3. activity focus

4. How to search local banks..?

5. My installed app wont display on home screen in emulator

6. how do i get the android unique id??

7. Indosat mulai melambat?