内部DBに基づいてビットマップの動的ギャラリーを表示するためにImagePagerAdapterを使用する私の問題があります。私のコードは、実際には位置に応じて正しいビットマップを表示しています。しかし、私は画像の説明も表示したい(textViewを使用)、私のコードは説明を表示していますが、imgの正しい説明を与えていません。 .
私は、説明とビットマップを格納している Two 配列を使用します。mydesc[] = 各画像の説明を保存するには mydraw[] = 自分のドローアブルを保存するには
この関数の位置を使用します
public Object instantiateItem(ViewGroup container, int position) {
ImagePager の私のコードがあります
private class ImagePagerAdapter extends PagerAdapter {
@Override
// Count the element on my array
public int getCount() {
return mydraw.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
/**
* Target: Displaying the data according to the position
*
*
* @param container, position
* @return imageView, The view displaying in the page
*/
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = MainActivitySocialisation.this;
ImageView imageView = new ImageView(context);
//TextView textView = new TextView(context);
int padding = context.getResources().getDimensionPixelSize(
R.dimen.padding_medium);
// Display the current image
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setImageDrawable(mydraw[position]); //(mImages[position]);
// Display the name of the Image
textView.setText(mydesc[position]);
((ViewPager) container).addView(imageView,0);
return imageView;
}
ご協力ありがとうございます。