當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.obtainTypedArray方法代碼示例

本文整理匯總了Java中android.content.res.Resources.obtainTypedArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.obtainTypedArray方法的具體用法?Java Resources.obtainTypedArray怎麽用?Java Resources.obtainTypedArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.obtainTypedArray方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCorrectShape

import android.content.res.Resources; //導入方法依賴的package包/類
private int getCorrectShape(Bundle bundle, Resources resources) {
    if (bundle != null) {
        int roundIcons = bundle.getInt(CALENDAR_ROUND_ICONS, 0);
        if (roundIcons != 0) {
            try {
                TypedArray obtainTypedArray = resources.obtainTypedArray(roundIcons);
                int resourceId = obtainTypedArray.getResourceId(dayOfMonth(), 0);
                obtainTypedArray.recycle();
                return resourceId;
            } catch (Resources.NotFoundException e) {
                e.printStackTrace();
            }
        }
    }

    return 0;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:18,代碼來源:IconThemer.java

示例2: LetterTileProvider

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Constructor for <code>LetterTileProvider</code>
 *
 * @param context The {@link Context} to use
 */
public LetterTileProvider(Context context) {
    final Resources res = context.getResources();

    mPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
    mPaint.setColor(Color.WHITE);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setAntiAlias(true);

    mColors = res.obtainTypedArray(R.array.letter_tile_colors);
    mTileLetterFontSize = res.getDimensionPixelSize(R.dimen.tile_letter_font_size);

    //mDefaultBitmap = BitmapFactory.decodeResource(res, android.R.drawable.);
    mDefaultBitmap = drawableToBitmap(ContextCompat.getDrawable(context, R.drawable.ic_person_white_24dp));
    mWidth = res.getDimensionPixelSize(R.dimen.letter_tile_size);
    mHeight = res.getDimensionPixelSize(R.dimen.letter_tile_size);
}
 
開發者ID:pchmn,項目名稱:MaterialChipsInput,代碼行數:22,代碼來源:LetterTileProvider.java

示例3: onCreate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //get POI data from resources
    Resources res = getActivity().getResources();
    titles = res.obtainTypedArray(R.array.poi_titles);
    categoryIDs = res.obtainTypedArray(R.array.poi_id);
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:9,代碼來源:CategoriesFragment.java

示例4: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    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,代碼行數:11,代碼來源:TileContentFragment.java

示例5: internalSetTargetResources

import android.content.res.Resources; //導入方法依賴的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:CableIM,項目名稱:Cable-Android,代碼行數:15,代碼來源:MultiWaveView.java

示例6: loadDrawableArray

import android.content.res.Resources; //導入方法依賴的package包/類
private ArrayList<TargetDrawable> loadDrawableArray(int resourceId) {
    Resources res = getContext().getResources();
    TypedArray array = res.obtainTypedArray(resourceId);
    final int count = array.length();
    ArrayList<TargetDrawable> drawables = new ArrayList<TargetDrawable>(count);
    for (int i = 0; i < count; i++) {
        TypedValue value = array.peekValue(i);
        TargetDrawable target = new TargetDrawable(res, value != null ? value.resourceId : 0);
        drawables.add(target);
    }
    array.recycle();
    return drawables;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:14,代碼來源:GlowPadView.java

示例7: ContentAdapter

import android.content.res.Resources; //導入方法依賴的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

示例8: ContentAdapter

import android.content.res.Resources; //導入方法依賴的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

示例9: onCreate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Set Collapsing Toolbar layout to the screen
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    // Set title of Detail page
    // collapsingToolbar.setTitle(getString(R.string.item_title));

    int postion = getIntent().getIntExtra(EXTRA_POSITION, 0);
    Resources resources = getResources();
    String[] places = resources.getStringArray(R.array.places);
    collapsingToolbar.setTitle(places[postion % places.length]);

    String[] placeDetails = resources.getStringArray(R.array.place_details);
    TextView placeDetail = (TextView) findViewById(R.id.place_detail);
    placeDetail.setText(placeDetails[postion % placeDetails.length]);

    String[] placeLocations = resources.getStringArray(R.array.place_locations);
    TextView placeLocation =  (TextView) findViewById(R.id.place_location);
    placeLocation.setText(placeLocations[postion % placeLocations.length]);

    TypedArray placePictures = resources.obtainTypedArray(R.array.places_picture);
    ImageView placePicutre = (ImageView) findViewById(R.id.image);
    placePicutre.setImageDrawable(placePictures.getDrawable(postion % placePictures.length()));

    placePictures.recycle();
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:32,代碼來源:DetailActivity.java

示例10: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    mChangasReference = FirebaseDatabase.getInstance().getReference("changas");
    ValueEventListener changaListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            List<String> ids = new ArrayList<String>();
            List<String> titles = new ArrayList<String>();
            List<String> descriptions = new ArrayList<String>();

            LENGTH = 0;
            for (DataSnapshot changaSnapshot: dataSnapshot.getChildren()) {
                Changa changa = changaSnapshot.getValue(Changa.class);
                System.out.println("idCategoria "+idCategoria);
                System.out.println("categoria changa: "+changa.category);

                if(changa.category == idCategoria) {
                    System.out.println("ENTRO");
                    ids.add(changa.id);
                    titles.add(changa.title);
                    System.out.println("titles0 size: "+titles.size());
                    descriptions.add(changa.body);
                    LENGTH++;
                }
            }
            mIDS = new String[LENGTH];
            mChangasTitle = new String[LENGTH];
            mChangasDescription = new String[LENGTH];

            ids.toArray(mIDS);
            System.out.println("titles1 size: "+titles.size());
            titles.toArray(mChangasTitle);
            System.out.println("mChangasTitle size: "+mChangasTitle.length);
            descriptions.toArray(mChangasDescription);
            System.out.println("mChangasDescription size: "+mChangasDescription.length);
            notifyDataSetChanged();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            // Getting Post failed, log a message
            Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
            // ...
        }
    };
    mChangasReference.addValueEventListener(changaListener);


    Resources resources = context.getResources();
    TypedArray a = resources.obtainTypedArray(R.array.changas_imgs);
    mChangasPictures = new Drawable[a.length()];
    for (int i = 0; i < mChangasPictures.length; i++) {
        mChangasPictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:56,代碼來源:ChangasPorCategoria.java

示例11: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    mChangasReference = FirebaseDatabase.getInstance().getReference("changas");
    ValueEventListener changaListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            currentIdInCard = FirebaseAuth.getInstance().getCurrentUser().getUid();
            LENGTH = 0;
            List<String> ids = new ArrayList<String>();
            List<String> titles = new ArrayList<String>();
            List<String> descriptions = new ArrayList<String>();
            List<Integer> categories = new ArrayList<Integer>();

            for (DataSnapshot changaSnapshot: dataSnapshot.getChildren()) {
                Changa changa = changaSnapshot.getValue(Changa.class);
                if (changa.postulantes != null) {
                    if (changa.postulantes.containsKey(currentIdInCard)) {
                        ids.add(changa.id);
                        titles.add(changa.title);
                        descriptions.add(changa.body);
                        categories.add(changa.category);
                        LENGTH++;
                    }
                }
            }

            mIDS = new String[LENGTH];
            mChangasTitle = new String[LENGTH];
            mChangasDescription = new String[LENGTH];
            mChangasCategory = new Integer[LENGTH];


            ids.toArray(mIDS);
            titles.toArray(mChangasTitle);
            descriptions.toArray(mChangasDescription);
            categories.toArray(mChangasCategory);
            notifyDataSetChanged();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            // Getting Post failed, log a message
            Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
            // ...
        }
    };
    mChangasReference.addValueEventListener(changaListener);


    Resources resources = context.getResources();
    TypedArray a = resources.obtainTypedArray(R.array.changas_imgs);
    mChangasPictures = new Drawable[a.length()];
    for (int i = 0; i < mChangasPictures.length; i++) {
        mChangasPictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:58,代碼來源:CardContentPostulacionActivaFragment.java

示例12: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    mChangasReference = FirebaseDatabase.getInstance().getReference("changas");
    ValueEventListener changaListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            List<String> ids = new ArrayList<String>();
            List<String> titles = new ArrayList<String>();
            List<String> descriptions = new ArrayList<String>();
            List<Integer> categories = new ArrayList<Integer>();

            LENGTH = 0;
            for (DataSnapshot changaSnapshot: dataSnapshot.getChildren()) {
                Changa changa = changaSnapshot.getValue(Changa.class);
                if(changa.status.equals("enProceso")) {
                    String idChanguero = changaSnapshot.child("changuero").getValue(String.class);
                    if (idChanguero != null) {
                        if (idChanguero.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) {
                            ids.add(changa.id);
                            titles.add(changa.title);
                            descriptions.add(changa.body);
                            categories.add(changa.category);
                            LENGTH++;
                        }
                    }
                }
            }
            mIDS = new String[LENGTH];
            mChangasTitle = new String[LENGTH];
            mChangasDescription = new String[LENGTH];
            mChangasCategory = new Integer[LENGTH];

            ids.toArray(mIDS);
            titles.toArray(mChangasTitle);
            descriptions.toArray(mChangasDescription);
            categories.toArray(mChangasCategory);
            notifyDataSetChanged();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            // Getting Post failed, log a message
            Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
            // ...
        }
    };
    mChangasReference.addValueEventListener(changaListener);


    Resources resources = context.getResources();
    TypedArray a = resources.obtainTypedArray(R.array.changas_imgs);
    mChangasPictures = new Drawable[a.length()];
    for (int i = 0; i < mChangasPictures.length; i++) {
        mChangasPictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:57,代碼來源:ListContentFragment.java

示例13: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    mChangasReference = FirebaseDatabase.getInstance().getReference("changas");
    ValueEventListener changaListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            LENGTH = 0;
            currentIdInCard = FirebaseAuth.getInstance().getCurrentUser().getUid();
            List<String> ids = new ArrayList<String>();
            List<String> titles = new ArrayList<String>();
            List<String> descriptions = new ArrayList<String>();
            List<Integer> categories = new ArrayList<Integer>();

            for (DataSnapshot changaSnapshot: dataSnapshot.getChildren()) {
                Changa changa = changaSnapshot.getValue(Changa.class);
                if (changa.uid.equals(currentIdInCard) && changa.status.equals("finalizada")) {

                    ids.add(changa.id);
                    titles.add(changa.title);
                    descriptions.add(changa.body);
                    categories.add(changa.category);
                    LENGTH++;
                }
            }
            mIDS = new String[LENGTH];
            mChangasTitle = new String[LENGTH];
            mChangasDescription = new String[LENGTH];
            mChangasCategory = new Integer[LENGTH];

            ids.toArray(mIDS);
            titles.toArray(mChangasTitle);
            descriptions.toArray(mChangasDescription);
            categories.toArray(mChangasCategory);
            notifyDataSetChanged();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            // Getting Post failed, log a message
            Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
            // ...
        }
    };
    mChangasReference.addValueEventListener(changaListener);

    Resources resources = context.getResources();
    TypedArray a = resources.obtainTypedArray(R.array.changas_imgs);
    mChangasPictures = new Drawable[a.length()];
    for (int i = 0; i < mChangasPictures.length; i++) {
        mChangasPictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:54,代碼來源:CardContentChangaFinalizadaFragment.java


注:本文中的android.content.res.Resources.obtainTypedArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。