gpt4 book ai didi

android - 如何将 URL 转换为 URI?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:15:10 24 4
gpt4 key购买 nike

我正在尝试使用此代码缓存这些图像...

但我总是在这里收到语法错误?

 Uri imageUri = new Uri(aURL);

这是我使用的代码。

                                URL aURL = new URL(myRemoteImages[position]);



Uri imageUri = new Uri(aURL);
if (new File(new File(myContext.getCacheDir(), "thumbnails"), "" + imageUri.hashCode()).exists())
{
String cachFile = ""+imageUri.hashCode();
FileInputStream fis;

try {
fis = new FileInputStream(cachFile);
Bitmap bm = BitmapFactory.decodeStream(fis);
i.setImageBitmap(bm);
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
/* Set the Width/Height of the ImageView. */
if(Build.VERSION.SDK_INT >= 11){
i.setLayoutParams(new Gallery.LayoutParams(450, 300));
}
else{
i.setLayoutParams(new Gallery.LayoutParams(125, 125));
}


} catch (FileNotFoundException e) {

Log.e("DEBUGTAG", "Remtoe Image Exception", e);





/* Image should be scaled as width/height are set. */
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
/* Set the Width/Height of the ImageView. */
if(Build.VERSION.SDK_INT >= 11){
i.setLayoutParams(new Gallery.LayoutParams(450, 300));

return i;
}
i.setLayoutParams(new Gallery.LayoutParams(125, 125));
return i;
}

最佳答案

关于android - 如何将 URL 转换为 URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6864454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com