0

写真を表示するための円形のインジケータを備えたViewPagerを使用しています。

代わりにいくつかの画像の URL を使用したい。実際には、ViewPager 内に円形のインジケーターを使用していくつかの画像を遅延ロードします。デフォルトのイメージ アダプターを遅延ロード アダプター (イメージの URL を取得する) に変更する必要があります。これで私を助けてください。

イメージ アダプターのコードは次のとおりです。

public class ImageAdapter extends BaseAdapter {

private LayoutInflater mInflater;
private static final int[] ids = { R.drawable.cupcake, R.drawable.donut, R.drawable.eclair, R.drawable.froyo,
        R.drawable.gingerbread, R.drawable.honeycomb, R.drawable.icecream };

public ImageAdapter(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    return ids.length;
}

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

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.image_item, null);
    }
    ((ImageView) convertView.findViewById(R.id.imgView)).setImageResource(ids[position]);
    return convertView;
}

}

メイン アクティビティでは、次のコードを使用して画像をランチします。

viewFlow = (ViewFlow) findViewById(R.id.viewflow);
    viewFlow.setAdapter(imgLoader, 5);
    CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
    viewFlow.setFlowIndicator(indic);
4

1 に答える 1