Я должен был получить ImageDisplay от ArrayJson, он поразит API 3 раза, эта функция отправит urlimage 3 раза
for(i=0; i<3; i++){send(UrlImage);}
это работает
private void getViewYoyo(){
String[] str = new String[3];
adapterViewPagerHot = new AdapterViewPagerHot(getActivity(), str);
str[0]="https://scx1.b-cdn.net/csz/news/800/2019/1-nasastessmis.jpg";
str[1]="https://i.chzbgr.com/full/8803531264/hD42E57C6/";
str[2]="https://scx1.b-cdn.net/csz/news/800/2019/1-nasastessmis.jpg";
viewPager.setAdapter(adapterViewPagerHot);
}
Но это не работает
public void getHighlightMainActivity(int ReceivedDummyUrutan, int ReceivedTotalThread, int ReceivedDummyID, String ReceivedDummyTitle, String ReceivedDummyPublishTime, String ReceivedDummyImageOri, String ReceivedDummyShortDescription){
String[] str = new String[ReceivedTotalThread];
adapterViewPagerHot = new AdapterViewPagerHot(getActivity(), str);
if(ReceivedDummyUrutan==0)
str[0]=ReceivedDummyImageOri;
if(ReceivedDummyUrutan==1)
str[1]=ReceivedDummyImageOri;
if(ReceivedDummyUrutan==2)
str[2]=ReceivedDummyImageOri;
if(ReceivedDummyUrutan==ReceivedTotalThread-1) {
viewPager.setAdapter(adapterViewPagerHot);
}
}
Это adapterViewPager.java
public class AdapterViewPagerHot extends PagerAdapter {
private Context mContext;
private LayoutInflater layoutInflater;
/*private Integer[] images = {R.drawable.cat_mermaid_cartoon_grumpy_cat_94004_1280x720,R.drawable.catnrobot,R.drawable.kleptocats,R.drawable.magiccat,R.drawable.flyingcat};*/
public String image_url[];
public AdapterViewPagerHot(Context context, String[] list) {
this.mContext = context;
this.image_url = list;
}
@Override
public int getCount() {
return image_url.length;
}
public void setUrls(String[] list){
this.image_url = list;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
public View vi;
@Override
public Object instantiateItem(ViewGroup container, final int position) {
layoutInflater = (LayoutInflater) this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vi = layoutInflater.inflate(R.layout.item_viewpagerdisplay, null);
final Context sContext = mContext;
ImageView imageView = vi.findViewById(R.id.imageView);
final ImageView ICONHotViewPagerSaving = vi.findViewById(R.id.ICON_HotViewPagerSaving);
/*imageView.setImageResource(images[position]);*/
Glide.with(sContext).load(image_url[position]).into(imageView);
vi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(sContext, "Slide" + (position+1) + "Clicked", Toast.LENGTH_SHORT).show();
}
});
final Boolean[] boollatestnewssaving = {false};
ICONHotViewPagerSaving.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (boollatestnewssaving[0] == true){
Toast.makeText(v.getContext(), "Turn Off Saved News ", Toast.LENGTH_SHORT).show();
ICONHotViewPagerSaving.setImageResource(R.drawable.saved_off);
boollatestnewssaving[0] = false;
/*updateSavedNewsSaving("update_newssaving", id, false);*/
} else if(boollatestnewssaving[0] == false) {
Toast.makeText(v.getContext(), "Turn On Saved News ", Toast.LENGTH_SHORT).show();
ICONHotViewPagerSaving.setImageResource(R.drawable.saved_on);
boollatestnewssaving[0] = true;
/*updateSavedNewsSaving("update_newssaving", id, true);*/
}
}
});
ViewPager vp = (ViewPager) container;
vp.addView(vi, 0);
return vi;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
ViewPager vp = (ViewPager) container;
View view = (View) object;
vp.removeView(view);
}
}
Что произойдет с функцией GetHighlight, так этопокажет только третье изображение, первое и второе изображение было пустым. Я не уверен, как заставить это работать так:
String test[]=new String[]{urlImageSend>>Image1, urlImageSend>Image2, urlImageSend>>Image3}
, нажав 3 раза