android 怎样把内容提供器里面的图片用Gallery组件显示...求代码..大神门不够分可以加...救命啊
publicViewgetView(intposition,ViewconvertView,ViewGroupparent){//TODOAuto-generatedme...
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
intent=new Intent(Intent.ACTION_GET_CONTENT);//设置动作
intent.setType(IMAGE_TYPE);//??
Uri uri=intent.getData();
String[] base={MediaStore.Images.Media.DATA};//数据列
//创建内容解析器
ContentResolver cp=getContentResolver();
//查询所有列
cursor=managedQuery(uri, base, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String path = cursor.getString(column_index);
ImageView iv=new ImageView(context);
iv.setImageResource(column_index);
iv.setLayoutParams(new Gallery.LayoutParams(120, 120));
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
return iv;
}
我用继承BaseAdapter来做..到最后imageview.setImageResource();应该填什么参数呢..是他的那一段uri............
对于例如图片..音频存放在哪里
相对的uri 是什么.... 展开
// TODO Auto-generated method stub
intent=new Intent(Intent.ACTION_GET_CONTENT);//设置动作
intent.setType(IMAGE_TYPE);//??
Uri uri=intent.getData();
String[] base={MediaStore.Images.Media.DATA};//数据列
//创建内容解析器
ContentResolver cp=getContentResolver();
//查询所有列
cursor=managedQuery(uri, base, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String path = cursor.getString(column_index);
ImageView iv=new ImageView(context);
iv.setImageResource(column_index);
iv.setLayoutParams(new Gallery.LayoutParams(120, 120));
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
return iv;
}
我用继承BaseAdapter来做..到最后imageview.setImageResource();应该填什么参数呢..是他的那一段uri............
对于例如图片..音频存放在哪里
相对的uri 是什么.... 展开
2个回答
2012-03-24
展开全部
/*
*
*/
private class downloadImage extends AsyncTask<String, Integer, Bitmap> {
Bitmap[] bms;
@Override
protected Bitmap doInBackground(String... arg0) {
/氏碧伍/ TODO Auto-generated method stub
bms = new Bitmap[arg0.length];
for (int i = 0; i <歼或 arg0.length; i++) {
Bitmap bm = Common.GetImages(arg0[i], "慧此219.136.252.234");
bms[i] = bm;
publishProgress(i);
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
adapter = new ImageAdapter(Activity_Gallery.this, bms);
galleryFlow.setAdapter(adapter);
adapter.notifyDataSetChanged();
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
adapter = new ImageAdapter(Activity_Gallery.this, bms);
galleryFlow.setAdapter(adapter);
adapter.notifyDataSetChanged();
galleryFlow.setSelection(5, true);
setGalleryMovie(true);
super.onPostExecute(result);
}
}
*
*/
private class downloadImage extends AsyncTask<String, Integer, Bitmap> {
Bitmap[] bms;
@Override
protected Bitmap doInBackground(String... arg0) {
/氏碧伍/ TODO Auto-generated method stub
bms = new Bitmap[arg0.length];
for (int i = 0; i <歼或 arg0.length; i++) {
Bitmap bm = Common.GetImages(arg0[i], "慧此219.136.252.234");
bms[i] = bm;
publishProgress(i);
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
adapter = new ImageAdapter(Activity_Gallery.this, bms);
galleryFlow.setAdapter(adapter);
adapter.notifyDataSetChanged();
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
adapter = new ImageAdapter(Activity_Gallery.this, bms);
galleryFlow.setAdapter(adapter);
adapter.notifyDataSetChanged();
galleryFlow.setSelection(5, true);
setGalleryMovie(true);
super.onPostExecute(result);
}
}
追问
大哥最重要那部分...imageAdapter怎么来的没写
还有我是想再SD卡里面读图片...不是下载
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询