2012-03-30 3 views
1
안드로이드

에 ViewPager 컬렉션에 추가하는 방법 나는이 URL을이 텍스트 뷰와 함께 작동 여기 http://android-developers.blogspot.in/2011/08/horizontal-view-swiping-with-viewpager.html비트 맵으로 이미지 URL을로드하고

을 따랐다.

  TextView tv = new TextView(cxt);  
     tv.setText("Bonjour PAUG " + position); 
     tv.setTextColor(Color.WHITE); 
     tv.setTextSize(30);   
     ((ViewPager) collection).addView(tv,0); 
     return tv;  

........................................... ...................

하지만 imageURL을 설정하고 Bitmap에로드해야하며 ViewPager에 추가해야합니다. .. 좋은 생각!

 public Object instantiateItem(View collection, int position) 
    { 
      LayoutInflater inflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      int resId = 0;  
     try 
      { 
       String saveimg= urls[position]; 
       String url1 = saveimg ; 
       URL ulrn = new URL(url1); 
       HttpURLConnection con = (HttpURLConnection)ulrn.openConnection(); 
       InputStream is = con.getInputStream(); 
       Bitmap bmp = BitmapFactory.decodeStream(is); 

       if (null != bmp) 
       { 
        ImageView Imgview=new ImageView(cxt); 
        Imgview.setImageBitmap(bmp); 

        ((ViewPager) collection).addView(Imgview, 0); 
        int i=0; 
        return Imgview; 


       } 
       else 

        System.out.println("The Bitmap is NULL"); 

       } 

      catch(Exception e) 
      { 
       int i=0; 
      } 
+0

내 문제 –

+0

안녕 해결 제안 당신은 당신의 솔루션을 제공해야합니까? 감사합니다 – markov00

+0

@ markov00 : 알아 두어야 할 사항 –

답변

관련 문제