Friday 15 July 2011

android - Get view of preference with custom layout -


itemprop = "text">

I have priority Android: layout GFT I have set the layout in Android: the priority property layout in the xml file

Now I have to initialize a button in the layout (this is the +1 button). I need to get the button in that creative method (this is the +1 button), but when I use the findViewById (button_id) , it blank.

Is there a way to view this preference?

Update: It seems that priority is not created after adding xml, so I get zero. Where can I find ViewById so that the button is already made?

Thank you.

Preferences xml:

  & lt; Android's Choice: Title = "Rate This App" Android: Key = "Rate" Android: widgetLayout = "@ layout / plusone_pref" /> & Lt; / PreferenceScreen & gt;   

preferred layout xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Comkgugl.andraidkgmskplskplusnebutton Ksmlns: android = "Actiteepi://schems.andraidkcom/apak/res/andraid" Ksmlns Plus = "Actiteepi://schems.andraidkcom/apak / Lib /com.google.android.gms.plus "android: id =" @ + id / plus_one_button "Android: layout_width =" wrap_content "Android: layout_height =" wrap_content "Android: layout_gravity =" center_vertical "android: focusable =" false " Plus: Size = "Standard" />    

You need to create a class that preference , Then override onBindView and you will have access to the view.

  increases the MyPreference priority class {... @ Override Protected Zero Adjustment View (View View) {Super .onBindView (see); See myView = (view) view.findViewById (R.id.my_id); // something ...)   

You probably need to override some additional methods, read about priority in preference -

No comments:

Post a Comment