ギャラリー内で一度に1つずつ、LinearLayoutのImageViewの上にTextViewで構成されたカスタムビューを表示したいとします。Androidの場合、カスタムビューはギャラリー内の画面に表示されません
問題は、私のカスタムビューが画面に表示されないことです。私は両側の他の意見の一部を見ることができ、私はこの問題を望んでいません。
ここは私のカスタムビューのXMLである:ここでgallery_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery_item_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/gallery_item_cardname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="20dp"
android:textStyle="bold"
android:text="@string/contrebandiers_lvl1"
android:textColor="@android:color/darker_gray"
/>
<ImageView
android:id="@+id/gallery_item_cardimg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:contentDescription="@string/app_name"
android:src="@drawable/contrebandiers_lvl1"
/>
</LinearLayout>
は私のアダプターの方法getVewのコードです:GTRoundDeckAdapter
public View getView(int position, View convertView, ViewGroup parent)
{
GalleryItem galleryItem;
if(convertView == null)
{
galleryItem = new GalleryItem();
convertView = mInflater.inflate(R.layout.gallery_item, null);
galleryItem.cardName = (TextView) convertView.findViewById(R.id.gallery_item_cardname);
galleryItem.cardImg = (ImageView) convertView.findViewById(R.id.gallery_item_cardimg);
convertView.setTag(galleryItem);
}
else
{
galleryItem = (GalleryItem) convertView.getTag();
}
GTCard gtCard = (GTCard) mRoundDeck.get(position);
galleryItem.cardName.setText(gtCard.getNameId());
galleryItem.cardImg.setImageResource(gtCard.getImgId());
return convertView;
}
私は感謝しますあなたのお手伝いをします。
サムエルは
はあなたの助けをいただき、ありがとうございます。 ViewPagerはまさに私が望むものです!チュートリアルはうまく動作し、使いやすいです。 – Samuel
ようこそ。 :) – sparkymat