自動輪播

    setContentView(R.layout.dianji_item);
        vp = (ViewPager) findViewById(R.id.vp);
        ima = (ImageView) findViewById(R.id.image01);
        tv1 = (TextView) findViewById(R.id.textView01);
        tv2 = (TextView) findViewById(R.id.shop_price01);
        
        
        Intent intent=getIntent();
        String name02=intent.getStringExtra("name");
        String image=intent.getStringExtra("ima");
        String jia=intent.getStringExtra("jiaqian");
        
        BitmapUtils bitmapUtils = new BitmapUtils(this);
        bitmapUtils.display(ima, image);
        tv1.setText(name02);
        tv2.setText(jia);
        
        
        list = new ArrayList<View>();
         ImageView img1 = new ImageView(this);
         ImageView img2 = new ImageView(this);
         
         BitmapUtils bitmapUtils1 = new BitmapUtils(this);
        bitmapUtils1.display(img1, "http://image.hmeili.com/yunifang/images/goods/85/goods_img/16052409165058122595118862.jpg");
        
         
         BitmapUtils bitmapUtils11 = new BitmapUtils(this);
        bitmapUtils11.display(img1, "http://image.hmeili.com/yunifang/images/goods/121/goods_img/160407143599311067893687095.jpg");
        
        list.add(img1);
        list.add(img2);
        

        vp.setAdapter(new PagerAdapter() {
            
            @Override
            public Object instantiateItem(ViewGroup container, int position) {
                container.addView(list.get(position));
                return list.get(position);
            }
            @Override
            public void destroyItem(ViewGroup container, int position,
                    Object object) {
                // TODO Auto-generated method stub
                container.removeView(list.get(position));
            }
            @Override
            public boolean isViewFromObject(View arg0, Object arg1) {
                // TODO Auto-generated method stub
                return arg0==arg1;
            }
            
            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return list.size();
            }
        });
    }

    

}
相關文章
相關標籤/搜索