I think you need to do findPreference instead of findViewById.
so like:
ib = (Preference) findPreference("displayimagekey");

Hope that helps.


On Jun 1, 3:20 pm, Noah <noah.belc...@gmail.com> wrote:
> Did you ever get this resolved? I'm having the same problem.
>
> Thanks
>
> On Apr 18, 1:27 am, hacksoft <hacks...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I can't seem to get a handle to the embedded widget (via widgetLayout)
> > in my preference.
>
> > My Preference XML is:
>
> > <PreferenceScreen
> >         xmlns:android="http://schemas.android.com/apk/res/android";
> >         android:key="first_preferencescreen">
>
> >                 <EditTextPreference android:key="displayname"
> >                                                 android:title="Display Name"
> >                                                 android:summary="Choose a 
> > display name" />
>
> >          <Preference android:id="@+id/displayimageview"
> >                                         android:key="displayimagekey"
> >                         android:title="Display Image"
> >                         android:summary="Select Display Image"
> >                         android:widgetLayout="@layout/displayimage"
> >                          />
>
> > </PreferenceScreen>
>
> > My widget XML is:
>
> >         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >                 android:layout_width="wrap_content"
> >                 android:layout_height="wrap_content"
> >                 android:orientation="horizontal"
> >                 >
>
> >         <ImageButton android:id="@+id/displayimagebutton"
> >                         android:layout_width="wrap_content"
> >                         android:layout_height="wrap_content"
> >                         android:padding="1dp"
> >                 />
>
> >      </LinearLayout>
>
> > I'm trying to get a handle on the displayimagebutton to embed an
> > ImageButton in a preference row.
>
> > My java code is:
> >           View v1 = null;
> >           v1 = findViewById(R.layout.preferences);
> >           ImageButton ib = null;
> >           if (v1 == null)
> >                   Log.d(SUBSYSTEM_TAG, "v1 = null");
> >           else
> >           {
> >                   ib = 
> > (ImageButton)v1.findViewById(R.id.displayimagebutton);
> >           }
>
> > I can't seem to get a view to the preferences I setup in
> > preferences.xml.  in my OnCreate() I'm calling:
> >  addPreferencesFromResource(R.layout.preferences);
>
> > and this seems to work fine since the preferences layout is
> > represented on the screen.  However I can't get a View to this layout
> > as my java code is trying above, so I can find the embedded widget.
>
> > I've tried: v1 = findViewById(R.id.displayimageview);
> > but that just returns null also.
>
> > Any ideas on how I can get the ImageButton reference to my
> > displayimagebutton?
>
> > I'm really disappointed on the lack of an Android example for this.
>
> > Thanks!
>
> > John Roberts
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group 
> > athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to