android Programming Glossary: context.obtainstyledattributes
Activity Layout: Fragment class: vs android:name attributes http://stackoverflow.com/questions/10162983/activity-layout-fragment-class-vs-androidname-attributes fname attrs.getAttributeValue null class TypedArray a context.obtainStyledAttributes attrs com.android.internal.R.styleable.Fragment if fname null..
Android FragmentTabHost - Not fully baked yet? http://stackoverflow.com/questions/13686282/android-fragmenttabhost-not-fully-baked-yet Context context AttributeSet attrs TypedArray a context.obtainStyledAttributes attrs new int android.R.attr.inflatedId 0 0 mContainerId a.getResourceId.. Context context AttributeSet attrs TypedArray a context.obtainStyledAttributes attrs new int android.R.attr.inflatedId 0 0 mContainerId a.getResourceId..
How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one? http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on set init int attrs android.R.attr.src TypedArray a context.obtainStyledAttributes set attrs TypedValue outValue new TypedValue if a.getValue 0..
How can I create my custom properties on xml for Android? http://stackoverflow.com/questions/2029719/how-can-i-create-my-custom-properties-on-xml-for-android context AttributeSet set super context set TypedArray a context.obtainStyledAttributes set R.styleable.custom_keyboard CharSequence s a.getString R.styleable.custom_keyboard_alternative_key_label..
Declaring a custom android UI element using XML http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml the android label view sample. LabelView.java TypedArray a context.obtainStyledAttributes attrs R.styleable.LabelView CharSequences a.getString R.styleable.LabelView_text..
Fast Scroll display problem with ListAdapter and SectionIndexer http://stackoverflow.com/questions/3225092/fast-scroll-display-problem-with-listadapter-and-sectionindexer attributes from xml if attrs null TypedArray typedArray context.obtainStyledAttributes attrs R.styleable.CustomFastScrollView mOverlayHeight typedArray.getDimensionPixelSize..
Defining custom attrs http://stackoverflow.com/questions/3441396/defining-custom-attrs int defStyle super context attrs defStyle TypedArray a context.obtainStyledAttributes attrs R.styleable.MyCustomView defStyle 0 String str a.getString..
Android: Want to set custom fonts for whole application not runtime http://stackoverflow.com/questions/4395309/android-want-to-set-custom-fonts-for-whole-application-not-runtime Context context AttributeSet attrs TypedArray values context.obtainStyledAttributes attrs R.styleable.CustomButton The value 0 is a default but..
android RadioButton button drawable gravity http://stackoverflow.com/questions/4407553/android-radiobutton-button-drawable-gravity AttributeSet attrs super context attrs TypedArray a context.obtainStyledAttributes attrs R.styleable.CompoundButton 0 0 buttonDrawable a.getDrawable..
Help with a custom View attributes inside a Android Library Project http://stackoverflow.com/questions/4461407/help-with-a-custom-view-attributes-inside-a-android-library-project attributes file which I use in my PieTimer TypedArray a context.obtainStyledAttributes attrs R.styleable.PieTimerView The XML styleable file looks..
How to: Define theme (style) item for custom widget http://stackoverflow.com/questions/4493947/how-to-define-theme-style-item-for-custom-widget super context attrs defStyle final TypedArray array context.obtainStyledAttributes attrs R.styleable.CustomImageButton defStyle R.style.Widget_ImageButton_Custom..
How to pass custom component parameters in java and xml http://stackoverflow.com/questions/4495511/how-to-pass-custom-component-parameters-in-java-and-xml that takes an AttributeSet you can do... TypedArray arr context.obtainStyledAttributes attrs R.styleable.MyComponent CharSequence foo_cs arr.getString..
How to layout a 'grid' of images in the center of the screen http://stackoverflow.com/questions/4592065/how-to-layout-a-grid-of-images-in-the-center-of-the-screen int defStyle super context attrs defStyle try TypedArray a context.obtainStyledAttributes attrs R.styleable.AspectGrid setNumColumns a.getInt R.styleable.AspectGrid_numColumns..
Android: Enable Scrollbars on Canvas-Based View http://stackoverflow.com/questions/4869276/android-enable-scrollbars-on-canvas-based-view true setVerticalScrollBarEnabled true TypedArray a context.obtainStyledAttributes R.styleable.View initializeScrollbars a a.recycle P.S. the solution..
How to implement expandable panels in Android? http://stackoverflow.com/questions/5165682/how-to-implement-expandable-panels-in-android AttributeSet attrs super context attrs TypedArray a context.obtainStyledAttributes attrs R.styleable.ExpandablePanel 0 0 How high the content should.. attrs mListener new DefaultOnExpandListener TypedArray a context.obtainStyledAttributes attrs R.styleable.ExpandablePanel 0 0 How high the content should..
How to add icons to Preference http://stackoverflow.com/questions/5765186/how-to-add-icons-to-preference setLayoutResource R.layout.preference_icon TypedArray a context.obtainStyledAttributes attrs R.styleable.IconPreferenceScreen defStyle 0 mIcon a.getDrawable..
Android: how to get value of an attribute in code? http://stackoverflow.com/questions/7896615/android-how-to-get-value-of-an-attribute-in-code int indexOfAttrTextSize 0 TypedArray a context.obtainStyledAttributes typedValue.data textSizeAttr int textSize a.getDimensionPixelSize..
Why so complex to set style from code in Android http://stackoverflow.com/questions/8369504/why-so-complex-to-set-style-from-code-in-android super context attrs defStyleAttr final TypedArray a context.obtainStyledAttributes attrs R.styleable.AwesomeButton defStyleAttr 0 Read AwesomeButton..
setTextAppearance through code referencing custom attribute http://stackoverflow.com/questions/8757764/settextappearance-through-code-referencing-custom-attribute be a style. Edit Maybe you should try this TypedArray a context.obtainStyledAttributes attrs new int R.attr.TextAppearance_Footer int id a.getResourceId..
Activity Layout: Fragment class: vs android:name attributes http://stackoverflow.com/questions/10162983/activity-layout-fragment-class-vs-androidname-attributes this question As Activity.onCreateView source says String fname attrs.getAttributeValue null class TypedArray a context.obtainStyledAttributes attrs com.android.internal.R.styleable.Fragment if fname null fname a.getString com.android.internal.R.styleable.Fragment_name..
Android FragmentTabHost - Not fully baked yet? http://stackoverflow.com/questions/13686282/android-fragmenttabhost-not-fully-baked-yet to this FragmentTabHost.java private void initFragmentTabHost Context context AttributeSet attrs TypedArray a context.obtainStyledAttributes attrs new int android.R.attr.inflatedId 0 0 mContainerId a.getResourceId 0 0 a.recycle super.setOnTabChangedListener this.. initFragmentTabHost context attrs private void initFragmentTabHost Context context AttributeSet attrs TypedArray a context.obtainStyledAttributes attrs new int android.R.attr.inflatedId 0 0 mContainerId a.getResourceId 0 0 a.recycle super.setOnTabChangedListener this..
How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one? http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on LayeredImageView Context context AttributeSet set super context set init int attrs android.R.attr.src TypedArray a context.obtainStyledAttributes set attrs TypedValue outValue new TypedValue if a.getValue 0 outValue setImageResource outValue.resourceId a.recycle private..
How can I create my custom properties on xml for Android? http://stackoverflow.com/questions/2029719/how-can-i-create-my-custom-properties-on-xml-for-android when the layout is loaded. public CustomKeyboard Context context AttributeSet set super context set TypedArray a context.obtainStyledAttributes set R.styleable.custom_keyboard CharSequence s a.getString R.styleable.custom_keyboard_alternative_key_label if s null this.setAlternativeKeyLabel..
Declaring a custom android UI element using XML http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml LabelView Sample If you want a complete example look at the android label view sample. LabelView.java TypedArray a context.obtainStyledAttributes attrs R.styleable.LabelView CharSequences a.getString R.styleable.LabelView_text attrs.xml declare styleable name LabelView..
Fast Scroll display problem with ListAdapter and SectionIndexer http://stackoverflow.com/questions/3225092/fast-scroll-display-problem-with-listadapter-and-sectionindexer private void init Context context AttributeSet attrs set all attributes from xml if attrs null TypedArray typedArray context.obtainStyledAttributes attrs R.styleable.CustomFastScrollView mOverlayHeight typedArray.getDimensionPixelSize R.styleable.CustomFastScrollView_overlayHeight..
Defining custom attrs http://stackoverflow.com/questions/3441396/defining-custom-attrs follows. public MyCustomView Context context AttributeSet attrs int defStyle super context attrs defStyle TypedArray a context.obtainStyledAttributes attrs R.styleable.MyCustomView defStyle 0 String str a.getString R.styleable.MyCustomView_my_custom_attribute do something..
Android: Want to set custom fonts for whole application not runtime http://stackoverflow.com/questions/4395309/android-want-to-set-custom-fonts-for-whole-application-not-runtime parseAttributes method from earlier private void parseAttributes Context context AttributeSet attrs TypedArray values context.obtainStyledAttributes attrs R.styleable.CustomButton The value 0 is a default but shouldn't ever be used since the attr is an enum int typeface..
android RadioButton button drawable gravity http://stackoverflow.com/questions/4407553/android-radiobutton-button-drawable-gravity extends RadioButton public RadioButtonCenter Context context AttributeSet attrs super context attrs TypedArray a context.obtainStyledAttributes attrs R.styleable.CompoundButton 0 0 buttonDrawable a.getDrawable 1 setButtonDrawable android.R.id.empty Drawable buttonDrawable..
Help with a custom View attributes inside a Android Library Project http://stackoverflow.com/questions/4461407/help-with-a-custom-view-attributes-inside-a-android-library-project public class PieTimerView extends View ... I also have a XML attributes file which I use in my PieTimer TypedArray a context.obtainStyledAttributes attrs R.styleable.PieTimerView The XML styleable file looks like this xml version 1.0 encoding utf 8 resources declare styleable..
How to: Define theme (style) item for custom widget http://stackoverflow.com/questions/4493947/how-to-define-theme-style-item-for-custom-widget CustomImageButton Context context AttributeSet attrs int defStyle super context attrs defStyle final TypedArray array context.obtainStyledAttributes attrs R.styleable.CustomImageButton defStyle R.style.Widget_ImageButton_Custom see below this.customAttr array.getString..
How to pass custom component parameters in java and xml http://stackoverflow.com/questions/4495511/how-to-pass-custom-component-parameters-in-java-and-xml pick anything out of the attributes in one of the constructors that takes an AttributeSet you can do... TypedArray arr context.obtainStyledAttributes attrs R.styleable.MyComponent CharSequence foo_cs arr.getString R.styleable.MyComponent_foo if foo_cs null Do something..
How to layout a 'grid' of images in the center of the screen http://stackoverflow.com/questions/4592065/how-to-layout-a-grid-of-images-in-the-center-of-the-screen 0 public AspectGrid Context context AttributeSet attrs int defStyle super context attrs defStyle try TypedArray a context.obtainStyledAttributes attrs R.styleable.AspectGrid setNumColumns a.getInt R.styleable.AspectGrid_numColumns mNumColumns setHorizontalSpacing..
Android: Enable Scrollbars on Canvas-Based View http://stackoverflow.com/questions/4869276/android-enable-scrollbars-on-canvas-based-view it on your custom view constructor setHorizontalScrollBarEnabled true setVerticalScrollBarEnabled true TypedArray a context.obtainStyledAttributes R.styleable.View initializeScrollbars a a.recycle P.S. the solution was tested on Android 2.0 I have forgot to add also..
How to implement expandable panels in Android? http://stackoverflow.com/questions/5165682/how-to-implement-expandable-panels-in-android context this context null public ExpandablePanel Context context AttributeSet attrs super context attrs TypedArray a context.obtainStyledAttributes attrs R.styleable.ExpandablePanel 0 0 How high the content should be in collapsed state mCollapsedHeight int a.getDimension.. Context context AttributeSet attrs super context attrs mListener new DefaultOnExpandListener TypedArray a context.obtainStyledAttributes attrs R.styleable.ExpandablePanel 0 0 How high the content should be in collapsed state mCollapsedHeight int a.getDimension..
How to add icons to Preference http://stackoverflow.com/questions/5765186/how-to-add-icons-to-preference AttributeSet attrs int defStyle super context attrs defStyle setLayoutResource R.layout.preference_icon TypedArray a context.obtainStyledAttributes attrs R.styleable.IconPreferenceScreen defStyle 0 mIcon a.getDrawable R.styleable.IconPreferenceScreen_icon @Override public..
Android: how to get value of an attribute in code? http://stackoverflow.com/questions/7896615/android-how-to-get-value-of-an-attribute-in-code the style just add this code int textSizeAttr new int android.R.attr.textSize int indexOfAttrTextSize 0 TypedArray a context.obtainStyledAttributes typedValue.data textSizeAttr int textSize a.getDimensionPixelSize indexOfAttrTextSize 1 a.recycle Now textSize will be the..
Why so complex to set style from code in Android http://stackoverflow.com/questions/8369504/why-so-complex-to-set-style-from-code-in-android AwesomeButton Context context AttributeSet attrs int defStyleAttr super context attrs defStyleAttr final TypedArray a context.obtainStyledAttributes attrs R.styleable.AwesomeButton defStyleAttr 0 Read AwesomeButton specific style attributes from a a.recycle More code..
setTextAppearance through code referencing custom attribute http://stackoverflow.com/questions/8757764/settextappearance-through-code-referencing-custom-attribute this R.style.Footer I think that the textAppearance must be a style. Edit Maybe you should try this TypedArray a context.obtainStyledAttributes attrs new int R.attr.TextAppearance_Footer int id a.getResourceId R.attr.TextAppearance_Footer defValue textView.setTextAppearance..
|