当前位置: 首页>>代码示例>>Java>>正文


Java TypedArray.length方法代码示例

本文整理汇总了Java中android.content.res.TypedArray.length方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.length方法的具体用法?Java TypedArray.length怎么用?Java TypedArray.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.TypedArray的用法示例。


在下文中一共展示了TypedArray.length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResIdArray

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int[] getResIdArray(Context context, int id) {
    final TypedArray idsarr = context.getResources().obtainTypedArray(id);
    int[] ids = new int[idsarr.length()];
    for (int i = 0; i < idsarr.length(); i++) {
        ids[i] = idsarr.getResourceId(i, 0);
    }
    idsarr.recycle();
    return ids;
}
 
开发者ID:quaap,项目名称:DodaTheExploda,代码行数:10,代码来源:SoundEffects.java

示例2: ContentAdapter

import android.content.res.TypedArray; //导入方法依赖的package包/类
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    mPlaceDesc = resources.getStringArray(R.array.place_desc);
    TypedArray a = resources.obtainTypedArray(R.array.place_avator);
    mPlaceAvators = new Drawable[a.length()];
    for (int i = 0; i < mPlaceAvators.length; i++) {
        mPlaceAvators[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
开发者ID:TORU0239,项目名称:android-design-library-master,代码行数:12,代码来源:ListContentFragment.java

示例3: getResourceIdArray

import android.content.res.TypedArray; //导入方法依赖的package包/类
private int[] getResourceIdArray(Context context, int arrayResId) {
    TypedArray ar = context.getResources().obtainTypedArray(arrayResId);
    int len = ar.length();
    int[] resIds = new int[len];
    for (int i = 0; i < len; i++) {
        resIds[i] = ar.getResourceId(i, 0);
    }
    ar.recycle();
    return resIds;
}
 
开发者ID:googlesamples,项目名称:android-ContentProviderPaging,代码行数:11,代码来源:ImageProvider.java

示例4: getResourcesIdArray

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int[] getResourcesIdArray(@ArrayRes int id) {
    TypedArray typedArray = mApplication.getResources().obtainTypedArray(id);
    int length = typedArray.length();
    int[] resArray = new int[length];
    for (int i = 0; i < length; i++) {
        int resourceId = typedArray.getResourceId(i, 0);
        resArray[i] = resourceId;
    }
    typedArray.recycle();
    return resArray;
}
 
开发者ID:iflove,项目名称:UIKit-ViewBlock,代码行数:12,代码来源:ResUtil.java

示例5: internalSetTargetResources

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void internalSetTargetResources(int resourceId) {
    Resources res = getContext().getResources();
    TypedArray array = res.obtainTypedArray(resourceId);
    int count = array.length();
    ArrayList<TargetDrawable> targetDrawables = new ArrayList<TargetDrawable>(count);
    for (int i = 0; i < count; i++) {
        Drawable drawable = array.getDrawable(i);
        targetDrawables.add(new TargetDrawable(res, drawable));
    }
    array.recycle();
    mTargetResourceId = resourceId;
    mTargetDrawables = targetDrawables;
    updateTargetPositions();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:MultiWaveView.java

示例6: loadDescriptions

import android.content.res.TypedArray; //导入方法依赖的package包/类
private ArrayList<String> loadDescriptions(int resourceId) {
    TypedArray array = getContext().getResources().obtainTypedArray(resourceId);
    final int count = array.length();
    ArrayList<String> targetContentDescriptions = new ArrayList<String>(count);
    for (int i = 0; i < count; i++) {
        String contentDescription = array.getString(i);
        targetContentDescriptions.add(contentDescription);
    }
    array.recycle();
    return targetContentDescriptions;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:MultiWaveView.java

示例7: getData

import android.content.res.TypedArray; //导入方法依赖的package包/类
private ArrayList<Image> getData() {
    final ArrayList<Image> imageItems = new ArrayList<>();
    TypedArray imgs = getResources().obtainTypedArray(R.array.image_ids);
    for (int i = imageStartId; i < imgs.length(); i++) {
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), imgs.getResourceId(i, -1));
        Image image = new Image(0l, null, null, 0, null, null);
        image.setTitle(Integer.toString(i));
        image.setImage(bitmap);
        imageItems.add(image);
    }
    return imageItems;
}
 
开发者ID:ProjektMedInf,项目名称:WiFiSDCryptoLocker,代码行数:13,代码来源:GalleryFragment.java

示例8: setLayerColors

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * Set layer colors from array resource
 *
 * @param arrayId array resource
 */
public T setLayerColors(@ArrayRes int arrayId) {
  TypedArray colorsArray = context.getResources().obtainTypedArray(arrayId);
  int[] colors = new int[colorsArray.length()];
  for (int i = 0; i < colorsArray.length(); i++) {
    colors[i] = colorsArray.getColor(i, Color.TRANSPARENT);
  }
  colorsArray.recycle();
  return setLayerColors(colors);
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:15,代码来源:GLAudioVisualizationView.java

示例9: ContentAdapter

import android.content.res.TypedArray; //导入方法依赖的package包/类
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    mPlaceDesc = resources.getStringArray(R.array.place_desc);
    TypedArray a = resources.obtainTypedArray(R.array.places_picture);
    mPlacePictures = new Drawable[a.length()];
    for (int i = 0; i < mPlacePictures.length; i++) {
        mPlacePictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
开发者ID:TORU0239,项目名称:android-design-library-master,代码行数:12,代码来源:CardContentFragment.java

示例10: loadTargetsDescriptions

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static ArrayList<String> loadTargetsDescriptions(Context ctxt, int resourceId) {
    TypedArray array = ctxt.getResources().obtainTypedArray(resourceId);
    final int count = array.length();
    ArrayList<String> targetContentDescriptions = new ArrayList<String>(count);
    for (int i = 0; i < count; i++) {
        String contentDescription = array.getString(i);
        targetContentDescriptions.add(contentDescription);
    }
    array.recycle();
    return targetContentDescriptions;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:LeftRightChooserUtils.java

示例11: CheckableRelativeLayout

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param context
 *            The context to operate in.
 * @param attrs
 *            The attributes defined in XML for this element.
 */
public CheckableRelativeLayout(final Context context, final AttributeSet attrs)
{
    super(context, attrs);
    
    TypedArray typedArray = null;
    
    // Cache the check box drawable.
    typedArray = context.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.listChoiceIndicatorMultiple });
    
    if (typedArray != null && typedArray.length() > 0)
        mCheckDrawable = typedArray.getDrawable(0);
    else
        // Fallback if the target theme doesn't define a check box drawable.
        // Perhaps an application specific drawable should be used instead
        // of null.
        mCheckDrawable = null;
    
    // Careful with resources like this, we don't need any memory leaks.
    typedArray.recycle();
    
    // Cache the radio button drawable.
    typedArray = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.listChoiceIndicatorSingle });
    
    if (typedArray != null && typedArray.length() > 0)
        mRadioDrawable = typedArray.getDrawable(0);
    else
        // Fallback if the target theme doesn't define a radio button
        // drawable.
        // Perhaps an application specific drawable should be used instead
        // of null
        mRadioDrawable = null;
    
    // Careful with resources like this, we don't need any memory leaks.
    typedArray.recycle();
    
    mIsChecked = false;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:47,代码来源:CheckableRelativeLayout.java

示例12: getRandomMaterialColor

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * @param typeColor the type of color as String
 * @return random color as an integer value
 */
private int getRandomMaterialColor(String typeColor) {
  int returnColor = Color.GRAY;
  int arrayId = context.getResources().getIdentifier("mdcolor_" + typeColor, "array", context.getPackageName());
  if (arrayId != 0) {
    TypedArray colors = context.getResources().obtainTypedArray(arrayId);
    int index = (int) (Math.random() * colors.length());
    returnColor = colors.getColor(index, Color.GRAY);
    colors.recycle();
  }
  return returnColor;
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:16,代码来源:GeoJsonPlugin.java

示例13: loadScreenIcons

import android.content.res.TypedArray; //导入方法依赖的package包/类
private Drawable[] loadScreenIcons() {
    TypedArray ta = getResources().obtainTypedArray(R.array.ld_activityScreenIcons);
    Drawable[] icons = new Drawable[ta.length()];
    for (int i = 0; i < ta.length(); i++) {
        int id = ta.getResourceId(i, 0);
        if (id != 0) {
            icons[i] = ContextCompat.getDrawable(this, id);
        }
    }
    ta.recycle();
    return icons;
}
 
开发者ID:yarolegovich,项目名称:SlidingRootNav,代码行数:13,代码来源:SampleActivity.java

示例14: getResourceIds

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int[] getResourceIds(Context c, @ArrayRes int array) {
  final TypedArray typedArray  = c.getResources().obtainTypedArray(array);
  final int[]      resourceIds = new int[typedArray.length()];
  for (int i = 0; i < typedArray.length(); i++) {
    resourceIds[i] = typedArray.getResourceId(i, 0);
  }
  typedArray.recycle();
  return resourceIds;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:10,代码来源:ResUtil.java

示例15: onCreate

import android.content.res.TypedArray; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    photoEditorActivity = (PhotoEditorActivity) getActivity();

    TypedArray images = getResources().obtainTypedArray(R.array.photo_editor_photos);

    stickerBitmaps = new ArrayList<>();
    for (int i = 0; i < images.length(); i++) {
        stickerBitmaps.add(decodeSampledBitmapFromResource(photoEditorActivity.getResources(), images.getResourceId(i, -1), 120, 120));
    }
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:13,代码来源:ImageFragment.java


注:本文中的android.content.res.TypedArray.length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。