图像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