Android グリッドビュー アダプターgetView()
が位置 0 を数回呼び出します。以下に、私の xml コードとログを示します。このコードで間違っていることを誰かに教えてもらえますか?
<GridView
android:id="@+id/reward_grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:background="@color/transparent"
android:horizontalSpacing="@dimen/reward_negative_space_medium"
android:listSelector="@color/Transparent"
android:numColumns="2"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="@dimen/reward_negative_space_medium" >
</GridView>
私のアダプターコードは @Override public View getView(int position, View convertVieww, ViewGroup parent) {
if(ShopBitesLog.IS_DEBUG_ENABLED)
Log.d(Tag, "Getview calling for position : "+ position);
if (convertView == null) {
holder = new ViewHolder();
final View convertView = inflator.inflate(R.layout.reward_grid_items, null);
holder.rewardGriditemTopImg = (ImageView)convertView
.findViewById(R.id.reward_grid_top_Img);
holder.rewardGriditemBites = (TextView)convertView
.findViewById(R.id.reward_grid_pointsTxt);
holder.reward_manin_linear = (RelativeLayout)convertView
.findViewById(R.id.reward_manin_linear);
holder.relative_reward_image = (RelativeLayout)convertView.findViewById(R.id.relative_reward_image);
holder.rewardText = (TextView)convertView.findViewById(R.id.rewardText);
holder.reward_first_relative=(RelativeLayout)convertView.findViewById(R.id.reward_first_relative);
holder.reward_second_relative=(RelativeLayout)convertView.findViewById(R.id.reward_second_relative);
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
if (rewardList.get(position).isAnnouncement()) {
holder.reward_second_relative.setVisibility(View.VISIBLE);
holder.reward_first_relative.setVisibility(View.GONE);
// holder.rewardGriditemTopImg.setImageResource(R.drawable.charity);
// holder.rewardText.setVisibility(View.VISIBLE);
holder.rewardText.setText(rewardList.get(position).getRewardText());
// holder.relative_reward_image.setVisibility(View.INVISIBLE);
} else {
holder.reward_first_relative.setVisibility(View.VISIBLE);
holder.reward_second_relative.setVisibility(View.GONE);
// holder.relative_reward_image.setVisibility(View.VISIBLE);
// holder.rewardText.setVisibility(View.INVISIBLE);
holder.rewardGriditemBites.setText(rewardList.get(position).getShop_bites() + " "
+ "bites");
imageBitmapLoader.DisplayImage(rewardList.get(position).getReward_image(), 0,
holder.rewardGriditemTopImg, true);
}
return convertView;
}
私のログはこちら。
03-01 11:06:06.349: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.381: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.503: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.519: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.519: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.540: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.560: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.560: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.580: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.590: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.720: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.730: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0 03-01 11:06:06.730: D/RewardGridAdapter(827): 位置を呼び出す Getview: 0