подскажите пожалуйста как можно получить и отобразить несколько картинок в ImageLoader.
Сейчас я получаю одну картинку ,но мне хотелось бы получать несколько картинок и затем при просмотре переключаться между картинками для лучшего представления продукта.
Это отрывок ImageLoader :
private Bitmap getBitmap(String url)
{
File f=fileCache.getFile(url);
//from SD cache
Bitmap b = decodeFile(f);
if(b!=null)
return b;
//from web
try {
Bitmap bitmap=null;
URL imageUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
conn.setConnectTimeout(40000);
conn.setReadTimeout(40000);
conn.setInstanceFollowRedirects(true);
InputStream is=conn.getInputStream();
OutputStream os = new FileOutputStream(f);
Constant.CopyStream(is, os);
Constant2.CopyStream(is, os);
Constant3.CopyStream(is, os);
os.close();
conn.disconnect();
bitmap = decodeFile(f);
return bitmap;
} catch (Throwable ex){
ex.printStackTrace();
if(ex instanceof OutOfMemoryError)
memoryCache.clear();
return null;
}
}
А это Активность:
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
// when finish parsing, hide progressbar
prgLoading.setVisibility(8);
// if internet connection and data available show data
// otherwise, show alert text
if((Menu_name != null) && IOConnect == 0){
sclDetail.setVisibility(0);
imageLoader.DisplayImage(Constant.AdminPageURL+Menu_image, imgPreview);
txtText.setText(Menu_name);
txtSubText.setText("Цена: " +Menu_price+" "+ActivityMenuList.Currency+"\n"+"Статус: "+Menu_serve);
txtDescription.loadDataWithBaseURL("", Menu_description, "text/html", "UTF-8", "");
txtDescription.setBackgroundColor(Color.parseColor("#e7e7e7"));
}else{
txtAlert.setVisibility(0);
}
}
public void parseJSONData(){
try {
// request data from menu detail API
URL url = new URL(MenuDetailAPI);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setConnectTimeout(20000);
connection.setReadTimeout(20000);
connection.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
String str = "";
while ((line = rd.readLine()) != null){
str += line;
}
// parse json data and store into tax and currency variables
JSONObject json = new JSONObject(str);
JSONArray data = json.getJSONArray("data"); // this is the "items: [ ] part
for (int i = 0; i < data.length(); i++) {
JSONObject object = data.getJSONObject(i);
JSONObject menu = object.getJSONObject("Menu_detail");
Menu_image = menu.getString("Menu_image");
Это отрывок xml Активности :
<pl.droidsonroids.gif.GifImageView
android:id="@+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/loading" />
Если кому понадобится то могу предоставить больше кода.