2012-09-26 132 views
0

我有一個需求,其中我需要有一個水平滾動視圖加載圖像。我從服務器獲取內容時沒有固定的圖像編號。水平滾動視圖中的圖像視圖?

庫已被廢棄,ViewPager應該被使用(如android docs

如何使用水平滾動視圖圖像的數量限制?

回答

0

從Github試用這個項目。這應該滿足您的需求。這裏是)的鏈接pakerfeldt/android-viewflow

+0

感謝您的建議。它只顯示一個圖像,您必須滾動才能查看其他圖像。我想在頁面中顯示3 - 4張圖片,當用戶滾動時我需要加載其他圖片 – Preethi

0
String RecentBooks="http://"; 

ArrayList<List<String>> arrrecentbooks= new ArrayList<List<String>>(); 
//HorizontalScrollview created programaticallly 

HorizontalScrollView scollviewh = new HorizontalScrollView(this); 

    View v1=null; 

    LinearLayout linear_pmain = new LinearLayout(this); 

     linear_pmain.setOrientation(LinearLayout.HORIZONTAL); 
     //  linear_pmain.setBackgroundDrawable(getResources().getDrawable(R.drawable.topshelf));bottomthumbnail 

// arrrecentbook包含圖像解析URI弗朗

int length=arrrecentbooks.size(); 

for(int j=0;j<length;j++) 
    { 
     LayoutInflater vii =  (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

     v1=vii.inflate(R.layout.thumbnailrowlayout, null); 

     List<String> listitem=arrrecentbooks.get(j); 

     String rimageurl=listitem.get(13); 

     String rbookprice=listitem.get(10); 

    img=(ImageView) v1.findViewById(R.id.imgg); 
     TextView txt=(TextView) v1.findViewById(R.id.txtg); 
     txt.setText("Rs."+rbookprice+"/-"); 
     txt.setTypeface(tf,Typeface.NORMAL);  


    img.setTag(new String[]{listitem.get(0),listitem.get(1),listitem.get(2),listitem.get(3),listitem.get(4),listitem.get(5),listitem.get(6),listitem.get(7),listitem.get(8),listitem.get(9),listitem.get(10),listitem.get(11),listitem.get(12),listitem.get(13),listitem.get(14),listitem.get(15),listitem.get(16),listitem.get(17),listitem.get(18),listitem.get(19),listitem.get(20),"recentbooks"}); 
//image loaded to image view 

     { 

      imageLoader=new ImageLoader(this); 

      imageLoader.DisplayImage(rimageurl, this, img); 
     } 
     img.setOnClickListener(myIItemClickListener); 

     linear_pmain.addView(v1); 
    } 

    scollviewh.addView(linear_pmain); 

    lrecentbooks.addView(scollviewh); 
//imgeview on itemclick listener 

公共OnClickListener myIItemClickListener =新OnClickListener({

@Override 

public void onClick(View v) { 


    try{ 

    RelativeLayout borderlyt=(RelativeLayout)findViewById(R.id.Booklyut); 

     borderlyt.setBackgroundResource(R.drawable.bgorange); 

     String[] Qtag = (String[]) v.getTag(); 


     Log.d("myItemClickListener", Qtag + ""); 

     //v.setBackgroundResource(R.drawable.bgorange); 

     Intent itemintent = new Intent(cxt,NoolDashboardDetailPage.class); 


     Bundle b = new Bundle(); 

     b.putStringArray("iarray", Qtag); 

     b.putInt("mflag", 0); 

     itemintent.putExtra("android.intent.extra.INTENT", b); 

     startActivityForResult(itemintent,2); 

    } 
    catch (Exception e) { 

     // TODO: handle exception 
    } 
} 
};