我有一个缩略图库。我想在每个缩略图上施加一个位图。结果图像应该是位图或可绘制的。因此,画廊现在由这些结果图像组成。当用户滚动浏览图库时,将显示结果图像。 我使用以下代码
public class GalleryVideo extends Activity {
private Integer[] imgId = {R.drawable.followtheleader,
R.drawable.fruitsalad,
R.drawable.gettingstrong,
R.drawable.gulpgulp,
R.drawable.heythereshakyshaky,
R.drawable.its_a_wiggly_circus,
R.drawable.lettucesing,
R.drawable.monkey_dance,
R.drawable.quack_quack,
R.drawable.vegetable_soup,
R.drawable.walk};
public void onCreate(Bundle savedInstanceState) {
....................
selected_photo = (ImageView)findViewById(R.id.selected_photo);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = BitmapFactory.decodeFile(photoPath, options);
selected_photo.setImageBitmap(bitmap);
gallery = (Gallery) findViewById(R.id.examplegallery);
gallery.setAdapter(new AddImgAdp(getApplicationContext()));
th_name = (ImageView)findViewById(R.id.th_name);
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
galleryVideoCounter = position;
Intent myIntent = new Intent(getApplicationContext(), StartDance.class);
startActivity(myIntent);
}
});
....................
}
public class AddImgAdp extends BaseAdapter {
int GalItemBg;
private Context cont;
public AddImgAdp(Context c) {
cont = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount() {
return imgId.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
try {
if(position > 0)
{
audioPosCount = position;
}
if(audioPosCount == 0 && audioPosCount != audioPosCount1)
{
galleryAudioCounter++;
audioPosCount1 = audioPosCount;
}
if(audioPosCount > 0 && audioPosCount != -1 && audioPosCount != audioPosCount1)
{
galleryAudioCounter++;
audioPosCount = position;
audioPosCount1 = audioPosCount;
}
return position;
} catch (Exception e) {
}
}
public View getView(int position, View convertView, ViewGroup parent) {
audioPosCount = 0;
ImageView imgView = new ImageView(getApplicationContext());
imgView.setImageResource(imgId[position]);
imgView.setLayoutParams(new Gallery.LayoutParams(((int)(width / 1.45)), ((int)(height / 1.6))));
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
return imgView;
}
}
}
我需要此功能的示例代码。