Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 字符串Url图像到位图_Android_Json_Image_Url - Fatal编程技术网

Android 字符串Url图像到位图

Android 字符串Url图像到位图,android,json,image,url,Android,Json,Image,Url,我是android新手,我有一个activity类,它从url获取Json字符串,并将Json数组转换成一个对象。我正在解析对象,但是图像返回为textview,这不是我想要的。 试图找到一个解决方案,我一直在寻找,但这只是给我的绘图图标,而不是我需要的图像。任何帮助或建议将不胜感激 下面是我的代码 ListAdapter adapter = new SimpleAdapter(this, List, R.layout.list, new String[] {T

我是android新手,我有一个activity类,它从url获取Json字符串,并将Json数组转换成一个对象。我正在解析对象,但是图像返回为textview,这不是我想要的。 试图找到一个解决方案,我一直在寻找,但这只是给我的绘图图标,而不是我需要的图像。任何帮助或建议将不胜感激

下面是我的代码

 ListAdapter adapter = new SimpleAdapter(this, List,
        R.layout.list,
        new String[] {TAG_PHOTOS }, new int[] {
                R.id.image});

setListAdapter(adapter);

// selecting single ListView item
final ListView lv = getListView();

// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        ImageView photoThumbnailUrl = ((ImageView) 
                    view.findViewById(R.id.image)); 
        Bitmap bMap = BitmapFactory.decodeResource(getResources(),
                    R.drawable.ic_launcher);
           Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 150, 100, true);
           photoThumbnailUrl.setImageBitmap(bMapScaled);
           photoThumbnailUrl.setImageResource(R.drawable.ic_launcher);
           photoThumbnailUrl.getDrawable();
        System.out.println(photoThumbnailUrl);
        lv.addView(photoThumbnailUrl);


          }
         });    
ListAdapter=new simpledapter(此,列表,
R.layout.list,
新字符串[]{TAG_PHOTOS},新int[]{
R.id.image});
setListAdapter(适配器);
//选择单个ListView项
最终ListView lv=getListView();
//在选择单个列表项时启动新屏幕
lv.setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父级、视图、,
内部位置,长id){
ImageView照片缩略图URL=((ImageView)
view.findviewbyd(R.id.image));
位图bMap=BitmapFactory.decodeResource(getResources(),
R.可牵引ic_发射器);
位图bMapScaled=Bitmap.createScaledBitmap(bMap,150100,true);
photoThumbnailUrl.setImageBitmap(bMapScaled);
photoThumbnailUrl.setImageResource(R.drawable.ic_启动器);
photoThumbnailUrl.getDrawable();
System.out.println(photoThumbnailUrl);
lv.addView(photoThumbnailUrl);
}
});    

要在android中使用imageview,您需要自定义适配器。我建议您使用LazyAdapter,因为您需要一些时间来使用它


信息不足,您得到TextView是什么意思?@JoxTraex我使用TextView测试图像是否已被解析,是的,它已被解析,但仅作为TextView。使用上述代码时,代码返回可绘制图标。