0

ギャラリービューに画像を読み込んでいますが、画像をスクロールしているときに、画像が不安定であるか、動かなくなっているように見えます。スムーズにスクロールするギャラリーが必要です。これは、10.1Samsungギャラクシータブレットをスクロールしたときにのみ発生します。これを解決するのを手伝ってください。

私は以下のコードを使用します

   @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final int pos = position;
        View retval = LayoutInflater.from(parent.getContext()).inflate(
                R.layout.horrizontallistitem, null);
        final ImageView imgitem = (ImageView) retval
                .findViewById(R.id.hlvItem);
        try {
            imgitem.setImageBitmap(CommonKeys
                    .getBitmapFromAsset("_images/" + dataObjects[pos]
                            + ".png"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }
        return retval;
    }
4

2 に答える 2

0

public class LazyAdapter extends BaseAdapter {

private Activity activity;
private String[] data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;

public LazyAdapter(Activity a, String[] d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {

    final int pos = position;
    final ImageView imgitem=null; 
    View retval = convertView;
    if(retval==null)
    { 
           retval = LayoutInflater.from(parent.getContext()).inflate(
                        R.layout.horrizontallistitem, null);
           imgitem = (ImageView) retval
                      .findViewById(R.id.hlvItem);
    }
   imageLoader.DisplayImage(dataObjects[position], imgitem);
   return retVal;
}

以下のリンクで遅延アダプターの実装を参照してください。

https://github.com/thest1/LazyList/tree/master/src/com/fedorvlasov/lazylist

この FileCache では、UrlConnection コードは役に立ちませんが、残りのコードで目標を達成できます

于 2012-02-15T10:00:49.567 に答える