0

活動の開始時の私GridViewのものは正しいように見えます

http://i.stack.imgur.com/p41lb.jpg

しかし、上下にスクロールした後、アイテムの位置が変わります

ここに画像の説明を入力

最初の行の最後の項目に大きなテキストがあります。これは私の問題だと思います。これは私のgetView()コードです

public View getView(int position, View convertView, ViewGroup parent) {
    View v;
    if (convertView == null) {
        LayoutInflater li = getLayoutInflater();
        v= li.inflate(R.layout.item, null);
    } else {
    v= convertView;
    }
    ImageView imageView = (ImageView) v.findViewById(R.id.grid_item_image);
    imageView.setImageResource(R.drawable.logo);
    TextView textView = (TextView) v.findViewById(R.id.grid_item_label);
    textView.setText(PersianReshape.reshape( Values[position].getName()));
    Typeface face = Typeface.createFromAsset(context.getAssets(),"font/BNazanin.ttf");
    textView.setTypeface(face);
    textView.setTextSize(farin.code.rahnamee.attrib.attribute.content_font_size);
    return gridView;
}
4

2 に答える 2

1

グリッド アイテムの高さはすべて均一にする必要があります。テキストの最小/最大行数を設定して高さを均一にし、ImageViewサイズも一貫させることを検討してください。ImageView1 つの方法は、単に ではなく、既知の固定サイズを に使用することですwrap_content

于 2012-12-01T20:03:41.777 に答える
0

このように getView メソッドを変更する必要があります。

public View getView(int position, View convertView, ViewGroup parent){
    // TODO Auto-generated method stub
    View v;
    if(convertView==null)
    {
        LayoutInflater li = getLayoutInflater();
        v = li.inflate(R.layout.icontext, null);
    }else{
        v = convertView;
    }
    TextView tv = (TextView)v.findViewById(R.id.icon_text);
    tv.setText(providers[position]);
    ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
    iv.setImageResource(R.drawable.icon);

    return v;
}

あなたの問題は、 convertView を使用すると、最初のレコードから古いデータが保存されることです。ビューの変換は、時間とメモリを消費するリソースからのレイアウト インフレーションを回避するために使用されます。古い膨張したビューを使用する必要がありますが、新しいデータを設定してください。

于 2013-03-02T04:46:12.433 に答える