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)
mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
                View layout = inflater.inflate(R.layout.brightness,
                                               (ViewGroup)
findViewById(R.id.layout_root));

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

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

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 R.id.seekbar.

Try calling layout.findViewById(R.id.seekbar) instead.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/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. OOT: Maknyus.....

Pulsa Anda telah terpotong Rp99000 untuk perpanjangan layanan XL Internet
Unlimited 30hari FUP 2GB. Informasi lebih lanjut www.xl.co.id

Wuuiooh..
Isengsiyangsiyanh

cakranexus + xlunlimited

-- 
"Indonesian Android Community [id-android]" 

2. DNS settings not working in android 1.6 x86 porting

Do you use the android-x86 source tree?
Or you do the x86 porting yourself?

Basically Android doesn't use /etc/resolv.conf.
Manually creating this file won't solve any problem.
(and it's impossible on android-x86, since the system is read-only)

Android uses the system property net.dns1 for dns setting.
Check if you have this property set correctly.




-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. Mail client yg support calendar

4. Micro SD Card class 6

5. VideoView path problem

6. Changing data format in a db column on next app version?

7. Changing data format in a db column on next app version?