How To Fetch Images On Viewpager From Server
I want to implement one app for image showing where images will come from server side and there will be maximum 4 images suppose that there are only one or two image on server then
Solution 1:
You need to check if other URLs are blank then you don't need to add into Array of Image. Change your code with below code and check.
String[] IMAGES={p0,p1,p2,p3};
for(int i=0;i<IMAGES.length;i++) {
if(!IMAGES[i].isEmpty()) {
ImagesArray.add(IMAGES[i]);
}
if (p0.equalsIgnoreCase("https://www.maangal.com/photos/large_"))
{
Log.e("pic**********", url1 + IMAGES[i]);
mPager.setVisibility(View.GONE);
}
}
Solution 2:
I have done it, if there is images then the array will ImagesArray.add(url1 + IMAGES[i]); and if there is no images nothing will add on arrayList
String[] IMAGES = {p0, p1, p2, p3};
for (int i = 0; i < IMAGES.length; i++) {
if (IMAGES[i].equalsIgnoreCase("") || IMAGES[i].equalsIgnoreCase("nophoto.jpg") || IMAGES[i].equalsIgnoreCase("https://www.maangal.com/photos/large_")) {
Log.e("piccc-----------", IMAGES[i]);
} else {
ImagesArray.add(url1 + IMAGES[i]);
Log.e("else", url1 + IMAGES[i]);
}
}
Post a Comment for "How To Fetch Images On Viewpager From Server"