當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。