Java Code Examples for android.content.res.TypedArray

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenuItemView.java

  18 
vote

public ActionMenuItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  mAllowTextWithIcon=getResources_getBoolean(context,R.bool.abs__config_allowActionMenuItemTextWithIcon);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SherlockActionMenuItemView,0,0);
  mMinWidth=a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth,0);
  a.recycle();
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenuItemView.java

  18 
vote

public ActionMenuItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  mAllowTextWithIcon=getResources_getBoolean(context,R.bool.abs__config_allowActionMenuItemTextWithIcon);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SherlockActionMenuItemView,0,0);
  mMinWidth=a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth,0);
  a.recycle();
}
 

Example 3

From project actionbar, under directory /actionbar-library/src/main/java/com/github/erd/actionbar/widget/.

Source file: Actionbar.java

  18 
vote

/** 
 * Class constructor.
 * @param context Current context.
 * @param attrs XML attributes.
 * @param style Style definition.
 */
public Actionbar(Context context,AttributeSet attrs,int style){
  super(context,attrs);
  final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.Actionbar,style,0);
  data=a.getString(R.styleable.Actionbar_title);
  draw=a.getDrawable(R.styleable.Actionbar_logo);
  back=a.getDrawable(R.styleable.Actionbar_background);
  type=a.getInt(R.styleable.Actionbar_type,TYPE_STANDARD);
  back=a.getDrawable(R.styleable.Actionbar_background);
  a.recycle();
  setId(R.id.action_bar);
  View.inflate(context,R.layout.actionbar,this);
}
 

Example 4

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/app/.

Source file: ActionBar.java

  18 
vote

public LayoutParams(Context c,AttributeSet attrs){
  super(c,attrs);
  TypedArray a=c.obtainStyledAttributes(attrs,ATTRS);
  gravity=a.getInt(0,-1);
  a.recycle();
}
 

Example 5

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: CommitView.java

  18 
vote

public CommitView(Context context,AttributeSet attrs){
  super(context,attrs);
  layoutInflater=LayoutInflater.from(context);
  layoutInflater.inflate(R.layout.commit_view,this);
  pager=(ViewPager)findViewById(R.id.pager);
  TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.CommitView);
  int viewPagerId=array.getResourceId(CommitView_viewPagerId,R.id.pager);
  array.recycle();
  Log.d(TAG,"viewPagerId=" + viewPagerId);
  pager.setId(viewPagerId);
  tabPageIndicator=(TabPageIndicator)findViewById(R.id.indicator);
}
 

Example 6

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenuItemView.java

  18 
vote

public ActionMenuItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  mAllowTextWithIcon=getResources_getBoolean(context,R.bool.abs__config_allowActionMenuItemTextWithIcon);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SherlockActionMenuItemView,0,0);
  mMinWidth=a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth,0);
  a.recycle();
}
 

Example 7

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenuItemView.java

  18 
vote

public ActionMenuItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  mAllowTextWithIcon=getResources_getBoolean(context,R.bool.abs__config_allowActionMenuItemTextWithIcon);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SherlockActionMenuItemView,0,0);
  mMinWidth=a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth,0);
  a.recycle();
}
 

Example 8

From project android-animation-backport, under directory /animation-backport/src/backports/animation/.

Source file: AccelerateInterpolator.java

  18 
vote

public AccelerateInterpolator(Context context,AttributeSet attrs){
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.AccelerateInterpolator);
  mFactor=a.getFloat(R.styleable.AccelerateInterpolator_factor,1.0f);
  mDoubleFactor=2 * mFactor;
  a.recycle();
}
 

Example 9

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/item/.

Source file: DrawableItem.java

  18 
vote

@Override public void inflate(Resources r,XmlPullParser parser,AttributeSet attrs) throws XmlPullParserException, IOException {
  super.inflate(r,parser,attrs);
  TypedArray a=r.obtainAttributes(attrs,R.styleable.DrawableItem);
  drawableId=a.getResourceId(R.styleable.DrawableItem_drawable,0);
  a.recycle();
}
 

Example 10

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/keyboard/internal/.

Source file: KeyboardBuilder.java

  18 
vote

public Row(Resources res,KeyboardParams params,XmlPullParser parser,int y){
  mParams=params;
  TypedArray keyboardAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard);
  mRowHeight=(int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr,R.styleable.Keyboard_rowHeight,params.mBaseHeight,params.mDefaultRowHeight);
  keyboardAttr.recycle();
  TypedArray keyAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard_Key);
  mDefaultKeyWidth=KeyboardBuilder.getDimensionOrFraction(keyAttr,R.styleable.Keyboard_Key_keyWidth,params.mBaseWidth,params.mDefaultKeyWidth);
  keyAttr.recycle();
  mCurrentY=y;
  mCurrentX=0.0f;
}
 

Example 11

From project android-viewflow, under directory /viewflow/src/org/taptwo/android/widget/.

Source file: CircleFlowIndicator.java

  18 
vote

/** 
 * The contructor used with an inflater
 * @param context
 * @param attrs
 */
public CircleFlowIndicator(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.CircleFlowIndicator);
  int activeType=a.getInt(R.styleable.CircleFlowIndicator_activeType,STYLE_FILL);
  int activeDefaultColor=0xFFFFFFFF;
  int activeColor=a.getColor(R.styleable.CircleFlowIndicator_activeColor,activeDefaultColor);
  int inactiveType=a.getInt(R.styleable.CircleFlowIndicator_inactiveType,STYLE_STROKE);
  int inactiveDefaultColor=0x44FFFFFF;
  int inactiveColor=a.getColor(R.styleable.CircleFlowIndicator_inactiveColor,inactiveDefaultColor);
  radius=a.getDimension(R.styleable.CircleFlowIndicator_radius,4.0f);
  fadeOutTime=a.getInt(R.styleable.CircleFlowIndicator_fadeOut,0);
  mCentered=a.getBoolean(R.styleable.CircleFlowIndicator_centered,false);
  initColors(activeColor,inactiveColor,activeType,inactiveType);
}
 

Example 12

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/view/menu/.

Source file: ActionMenuItemView.java

  18 
vote

public ActionMenuItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs);
  mAllowTextWithIcon=getResources_getBoolean(context,R.bool.abs__config_allowActionMenuItemTextWithIcon);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SherlockActionMenuItemView,0,0);
  mMinWidth=a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth,0);
  a.recycle();
}
 

Example 13

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: ViewPager.java

  18 
vote

public LayoutParams(Context context,AttributeSet attrs){
  super(context,attrs);
  final TypedArray a=context.obtainStyledAttributes(attrs,LAYOUT_ATTRS);
  gravity=a.getInteger(0,Gravity.NO_GRAVITY);
  a.recycle();
}
 

Example 14

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: IconPreferenceScreen.java

  18 
vote

public IconPreferenceScreen(Context context,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);
}
 

Example 15

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: EvenlySpacedLayout.java

  18 
vote

public EvenlySpacedLayout(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.EvenlySpacedLayout,0,0);
  mHorizontal=(0 == a.getInt(R.styleable.EvenlySpacedLayout_orientation,0));
  mKeepEndSpace=a.getBoolean(R.styleable.EvenlySpacedLayout_keepEndSpace,true);
  a.recycle();
}
 

Example 16

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/photoeditor/actions/.

Source file: ColorSeekBar.java

  18 
vote

public ColorSeekBar(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=getResources().obtainTypedArray(R.array.color_picker_colors);
  colors=new int[a.length()];
  for (int i=0; i < a.length(); i++) {
    colors[i]=a.getColor(i,0x000000);
  }
  a.recycle();
  setMax(colors.length - 1);
}
 

Example 17

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: CallForwardEditPreference.java

  18 
vote

public CallForwardEditPreference(Context context,AttributeSet attrs){
  super(context,attrs);
  phone=PhoneFactory.getDefaultPhone();
  mSummaryOnTemplate=this.getSummaryOn();
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.CallForwardEditPreference,0,R.style.EditPhoneNumberPreference);
  mServiceClass=a.getInt(R.styleable.CallForwardEditPreference_serviceClass,CommandsInterface.SERVICE_CLASS_VOICE);
  reason=a.getInt(R.styleable.CallForwardEditPreference_reason,CommandsInterface.CF_REASON_UNCONDITIONAL);
  a.recycle();
  if (DBG)   Log.d(LOG_TAG,"mServiceClass=" + mServiceClass + ", reason="+ reason);
}
 

Example 18

From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/preferences/.

Source file: IconPreferenceScreen.java

  18 
vote

public IconPreferenceScreen(Context context,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);
}
 

Example 19

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/keyboard/internal/.

Source file: KeyboardBuilder.java

  18 
vote

public Row(Resources res,KeyboardParams params,XmlPullParser parser,int y){
  mParams=params;
  TypedArray keyboardAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard);
  mRowHeight=(int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr,R.styleable.Keyboard_rowHeight,params.mBaseHeight,params.mDefaultRowHeight);
  keyboardAttr.recycle();
  TypedArray keyAttr=res.obtainAttributes(Xml.asAttributeSet(parser),R.styleable.Keyboard_Key);
  mDefaultKeyWidth=KeyboardBuilder.getDimensionOrFraction(keyAttr,R.styleable.Keyboard_Key_keyWidth,params.mBaseWidth,params.mDefaultKeyWidth);
  keyAttr.recycle();
  mCurrentY=y;
  mCurrentX=0.0f;
}
 

Example 20

From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/.

Source file: PullToRefreshBase.java

  17 
vote

@SuppressWarnings("deprecation") private void init(Context context,AttributeSet attrs){
  setOrientation(LinearLayout.VERTICAL);
  ViewConfiguration config=ViewConfiguration.get(context);
  mTouchSlop=config.getScaledTouchSlop();
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.PullToRefresh);
  if (a.hasValue(R.styleable.PullToRefresh_ptrMode)) {
    mMode=Mode.mapIntToMode(a.getInteger(R.styleable.PullToRefresh_ptrMode,0));
  }
  mRefreshableView=createRefreshableView(context,attrs);
  addRefreshableView(context,mRefreshableView);
  mHeaderLayout=createLoadingLayout(context,Mode.PULL_DOWN_TO_REFRESH,a);
  mFooterLayout=createLoadingLayout(context,Mode.PULL_UP_TO_REFRESH,a);
  if (a.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
    Drawable background=a.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
    if (null != background) {
      setBackgroundDrawable(background);
    }
  }
  if (a.hasValue(R.styleable.PullToRefresh_ptrAdapterViewBackground)) {
    Drawable background=a.getDrawable(R.styleable.PullToRefresh_ptrAdapterViewBackground);
    if (null != background) {
      mRefreshableView.setBackgroundDrawable(background);
    }
  }
  if (a.hasValue(R.styleable.PullToRefresh_ptrOverScroll)) {
    mOverScrollEnabled=a.getBoolean(R.styleable.PullToRefresh_ptrOverScroll,true);
  }
  handleStyledAttributes(a);
  a.recycle();
  updateUIForMode();
}
 

Example 21

From project android-tether, under directory /android-misc-widgets/src/org/miscwidgets/widget/.

Source file: Panel.java

  17 
vote

public Panel(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.Panel);
  mDuration=a.getInteger(R.styleable.Panel_animationDuration,750);
  mPosition=a.getInteger(R.styleable.Panel_position,BOTTOM);
  mLinearFlying=a.getBoolean(R.styleable.Panel_linearFlying,false);
  mWeight=a.getFraction(R.styleable.Panel_weight,0,1,0.0f);
  if (mWeight < 0 || mWeight > 1) {
    mWeight=0.0f;
    Log.w(TAG,a.getPositionDescription() + ": weight must be > 0 and <= 1");
  }
  mOpenedHandle=a.getDrawable(R.styleable.Panel_openedHandle);
  mClosedHandle=a.getDrawable(R.styleable.Panel_closedHandle);
  RuntimeException e=null;
  mHandleId=a.getResourceId(R.styleable.Panel_handle,0);
  if (mHandleId == 0) {
    e=new IllegalArgumentException(a.getPositionDescription() + ": The handle attribute is required and must refer to a valid child.");
  }
  mContentId=a.getResourceId(R.styleable.Panel_content,0);
  if (mContentId == 0) {
    e=new IllegalArgumentException(a.getPositionDescription() + ": The content attribute is required and must refer to a valid child.");
  }
  a.recycle();
  if (e != null) {
    throw e;
  }
  mOrientation=(mPosition == TOP || mPosition == BOTTOM) ? VERTICAL : HORIZONTAL;
  setOrientation(mOrientation);
  mState=State.READY;
  mGestureListener=new PanelOnGestureListener();
  mGestureDetector=new GestureDetector(mGestureListener);
  mGestureDetector.setIsLongpressEnabled(false);
  setBaselineAligned(false);
}
 

Example 22

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/remotesandbox/ui/tablet/.

Source file: DashboardBoxLayout.java

  17 
vote

public DashboardBoxLayout(Context context,AttributeSet attrs){
  super(context,attrs);
  String service=Context.LAYOUT_INFLATER_SERVICE;
  LayoutInflater li=(LayoutInflater)getContext().getSystemService(service);
  li.inflate(R.layout.dashboard_box,this,true);
  final TextView title=(TextView)findViewById(R.id.dashboardbox_title);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.DashboardBoxLayout);
  CharSequence s=a.getString(R.styleable.DashboardBoxLayout_title);
  if (s != null) {
    title.setText(s);
  }
  final ImageView icon=(ImageView)findViewById(R.id.dashboardbox_icon);
  icon.setImageResource(a.getResourceId(R.styleable.DashboardBoxLayout_icon,R.drawable.ic_dashboard_movies));
  findViewById(R.id.dashboardbox_titlebar).setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (mOnTitleClickListener != null) {
        mOnTitleClickListener.onClick(v);
      }
    }
  }
);
}
 

Example 23

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.

Source file: BookStoreFactory.java

  17 
vote

private static void addStore(Context context,XmlResourceParser parser,AttributeSet attrs,HashMap<String,BooksStore> stores){
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.BookStore);
  final String name=a.getString(R.styleable.BookStore_name);
  if (TextUtils.isEmpty(name)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a name");
  }
  final String label=a.getString(R.styleable.BookStore_label);
  if (TextUtils.isEmpty(label)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a label");
  }
  final String storeClass=a.getString(R.styleable.BookStore_storeClass);
  if (TextUtils.isEmpty(name)) {
    throw new InflateException(parser.getPositionDescription() + ": A store must have a class");
  }
  a.recycle();
  try {
    Class<?> klass=Class.forName(storeClass);
    Constructor<?> constructor=klass.getDeclaredConstructor(String.class,String.class);
    constructor.setAccessible(true);
    BooksStore store=(BooksStore)constructor.newInstance(name,label);
    stores.put(name,store);
  }
 catch (  ClassNotFoundException e) {
  }
catch (  NoSuchMethodException e) {
    throw new InflateException(parser.getPositionDescription() + ": The book store " + storeClass+ " does not have a matching constructor");
  }
catch (  IllegalAccessException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
catch (  InvocationTargetException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
catch (  InstantiationException e) {
    throw new InflateException(parser.getPositionDescription() + ": Could not create the " + "book store",e);
  }
}
 

Example 24

From project Android_1, under directory /LeftNavBarExample/LeftNavBarLibrary/src/com/example/google/tv/leftnavbar/.

Source file: TitleBarView.java

  17 
vote

public TitleBarView(Context context,AttributeSet attrs){
  super(context,attrs,0);
  mContext=context;
  mVisibilityController=new VisibilityController(this);
  TypedArray a=context.obtainStyledAttributes(attrs,new int[]{android.R.attr.windowTitleStyle,android.R.attr.defaultValue});
  mIsLegacy=a.getBoolean(a.getIndex(1),false);
  if (mIsLegacy) {
    mTitleResource=a.getResourceId(a.getIndex(0),0);
  }
 else {
    a.recycle();
    a=context.obtainStyledAttributes(null,new int[]{android.R.attr.titleTextStyle,android.R.attr.subtitleTextStyle},android.R.attr.actionBarStyle,0);
    mTitleResource=a.getResourceId(a.getIndex(0),0);
    mSubtitleResource=a.getResourceId(a.getIndex(1),0);
  }
  a.recycle();
}
 

Example 25

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: SlidingPanel.java

  17 
vote

public SlidingPanel(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.SlidingPanel,defStyle,0);
  int buttonId=a.getResourceId(R.styleable.SlidingPanel_button,0);
  if (buttonId == 0) {
    throw new IllegalArgumentException("The button attribute is required and must refer" + " to a valid child");
  }
  int anchorId=a.getResourceId(R.styleable.SlidingPanel_anchor,0);
  if (anchorId == buttonId) {
    throw new IllegalArgumentException("The anchor attribute is required and must refer" + " to a different child");
  }
  int contentId=a.getResourceId(R.styleable.SlidingPanel_content,0);
  if (contentId == anchorId || contentId == buttonId) {
    throw new IllegalArgumentException("The content attribute is required and must refer" + " to a different child");
  }
  mOpenOverlap=a.getDimensionPixelSize(R.styleable.SlidingPanel_openOverlap,0);
  mClosedLimit=a.getDimensionPixelSize(R.styleable.SlidingPanel_closedLimit,0);
  a.recycle();
  mButtonId=buttonId;
  mAnchorId=anchorId;
  mContentId=contentId;
  mToggler=new Toggler();
}
 

Example 26

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/dictionaries/.

Source file: ResourceBinaryDictionary.java

  17 
vote

@Override protected Void doInBackground(Void... v){
  Resources pkgRes=mAppContext.getResources();
  final int[] resId;
  final String dictResType=pkgRes.getResourceTypeName(mDictResId);
  if (dictResType.equalsIgnoreCase("raw")) {
    resId=new int[]{mDictResId};
  }
 else {
    Log.d(TAG,"type " + dictResType);
    TypedArray a=pkgRes.obtainTypedArray(mDictResId);
    resId=new int[a.length()];
    for (int index=0; index < a.length(); index++)     resId[index]=a.getResourceId(index,0);
  }
  GCUtils.getInstance().peformOperationWithMemRetry(TAG,new MemRelatedOperation(){
    public void operation(){
      try {
        mNativeDict=0;
        loadDictionary(mAppContext,resId);
      }
 catch (      UnsatisfiedLinkError ex) {
        Log.w(TAG,"Failed to load binary JNI connection! Error: " + ex.getMessage());
      }
    }
  }
,false);
  return null;
}