1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.bidi; 17 18 import android.content.Context; 19 import android.view.View; 20 import android.view.ViewGroup; 21 import android.widget.BaseAdapter; 22 import android.widget.ImageView; 23 import android.widget.ImageView.ScaleType; 24 25 public class BiDiTestGalleryImages extends BaseAdapter { 26 int mGalleryItemBackground; 27 private Context mContext; 28 29 private Integer[] mImageIds = { 30 R.drawable.alphabet_a, 31 R.drawable.alphabet_b, 32 R.drawable.alphabet_c, 33 R.drawable.alphabet_d, 34 R.drawable.alphabet_e, 35 R.drawable.alphabet_f, 36 R.drawable.alphabet_g, 37 R.drawable.alphabet_h, 38 R.drawable.alphabet_i, 39 R.drawable.alphabet_j, 40 }; 41 42 public BiDiTestGalleryImages(Context c) { 43 mContext = c; 44 } 45 46 @Override 47 public int getCount() { 48 return mImageIds.length; 49 } 50 51 @Override 52 public Object getItem(int position) { 53 return position; 54 } 55 56 @Override 57 public long getItemId(int position) { 58 return position; 59 } 60 61 @Override 62 public View getView(int position, View convertView, ViewGroup parent) { 63 ImageView i = new ImageView(mContext); 64 i.setImageResource(mImageIds[position]); 65 i.setScaleType(ScaleType.CENTER_INSIDE); 66 return i; 67 } 68 } 69