圖像URL我是新來的Android域..顯示在列表視圖
我與小應用程序的工作..
我需要的是?
我有一個數組列表中的視頻網址和圖像網址,它從數據庫中作爲json對象進行檢索並存儲在單獨的數組中。我想這個數組列表的圖像應該顯示在列表視圖與文本。
如何實現?請幫助我..
我已經通過谷歌去了,但我仍然沒有明顯的例子。請任何一個幫助我..
感謝很多提前...
public class act extends Activity { /** Called when the activity is first created. */ static String uri1="http://i3.ytimg.com/vi/bQaWsVQSLdY/default.jpg"; static String uri2="http://i4.ytimg.com/vi/cJQCniWQdno/mqdefault.jpg"; static String uri3="http://i1.ytimg.com/vi/D8dA4pE5hEY/mqdefault.jpg"; public static String[] urls={uri1,uri2,uri3}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); GridView grd=(GridView)findViewById(R.id.gridView1); grd.setAdapter(new ImageAdapter(this)); grd.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent,View v,int pos,long id) { Toast.makeText(getBaseContext(),"pic"+(pos+1)+"select ",Toast.LENGTH_SHORT).show(); } }); } public class ImageAdapter extends BaseAdapter { private Context context; private int itemBackground; ImageAdapter(Context c) { context=c; TypedArray a=obtainStyledAttributes(R.styleable.Gallery1); itemBackground=a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground,0); a.recycle(); } public int getCount() { return urls.length; } public Object getItem(int pos) { return pos; } public long getItemId(int pos) { return pos; } public View getView(int pos,View cv,ViewGroup vg) { ImageView imageview=new ImageView(context); imageview.setImageResource(urls[pos]); imageview.setScaleType(ImageView.ScaleType.FIT_XY); imageview.setLayoutParams(new Gallery.LayoutParams(150,120)); imageview.setBackgroundResource(itemBackground); return imageview; } }
}
我嘗試像this..i不能抽到圖像...
這是一個不同的問題與產品總數賞金? http://stackoverflow.com/questions/16212883/images-url-are-not-displaying-in-grid – Nezam 2013-04-30 08:15:47