1

画像とテキストを含むカテゴリを次のように表示するグリッドビューを作成しました。

 <GridView
            android:id="@+id/gridViewCategories"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#c7c9bf"
            android:fadingEdge="none"
            android:horizontalSpacing="1dp"
            android:listSelector="@null"
            android:numColumns="3"
            android:scrollbars="none"
            android:verticalSpacing="1dp" >

 </GridView>

これは私のアダプターの getView のコードです

public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;

    if (convertView == null) {
        LayoutInflater inflater = ((Activity) context)
                .getLayoutInflater();
        convertView = inflater.inflate(R.layout.poi_category_item, parent,
                false);
        holder = new ViewHolder();
        holder.imageView = (ImageView) convertView.findViewById(R.id.imageViewIcon);
        holder.textView = (TextView) convertView.findViewById(R.id.textViewName);
        convertView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    Category category = list.get(position);

    if (category != null) {

        if (Build.VERSION.SDK_INT < 11) {
            convertView.setBackgroundColor(Color.parseColor("#f8f8f3"));
        }

        holder.textView.setLines(2);
        holder.imageView.setImageResource(category.getResourceId());

        if (category.getId() > 0) {
            holder.imageView.setVisibility(View.VISIBLE);
        } else {
            holder.imageView.setVisibility(View.INVISIBLE);
            holder.textView.setVisibility(View.INVISIBLE);
        }
        holder.textView.setText(category.getName());
    }
    return convertView;
}

上下にスクロールすると、テキストビューに属するテキストの一部がランダムに消えます。エラーはありませんが。何が起こっているのかわかりません。私のコードに何か問題がありますか?

4

1 に答える 1