我是android域的新手..
我正在使用小应用程序..
我需要的是??
我在数组列表中有视频 url 和图像 url,它们从数据库中检索为 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; } }
}
我尝试这样..我无法获得图像...