Imageview and PagerAdapter

a 夏天 提交于 2019-12-03 15:05:44

for(int i = 0; i < position; i++){ image[i] = new ImageView(cxt); image[i].setLayoutParams(content_params); createimage(image[i], list_url.get(position)); container.addView(image[i]); }

I don't think you have to do it in a for loop. You can perhaps look at the sample in compatibility library. I think it automatically instantiate an item for a position. Here is an sample I found after googling-

@Override
    public Object instantiateItem(View collection, int position) {
        TextView tv = new TextView(cxt);
        tv.setText("Bonjour PAUG " + position);
        tv.setTextColor(Color.WHITE);
        tv.setTextSize(30);

        ((ViewPager) collection).addView(tv,0);

        return tv;
    }

I have never used a PagerAdapter before but I doubt you can return a view in instantiateItem and then only after download the resource (in the AsyncTask). When the AsyncTask sets the background image, I think it's too late, the adapter has already returned the view...

You'll probably need to invalidate the view at some point...

I'm sorry it was a mistake but wow i can't even describe -> I didn't put the Permission :

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

and i put

d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicWidth());

int the onPostExecute because i didn't want the images to be all weird.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!