Android 使用 Java 不会显示图片,使用 Picasa 依赖。

huangapple go评论67阅读模式
英文:

Android using Java won't display image using picasa dependence

问题

# Java代码中用于获取图像路径的代码行

jsonObject.getString("image"); // 这是路径

## 我的JSON文件

{
"image": "/Users/jz/Desktop/RwandanMeal/Omellete.jpg"
}


## 日志输出结果

{
"image": "/Users/jz/Desktop/RwandanMeal/ugari.jpg"
}


正如您所看到的,我的路径已经被篡改,这可能是原因之一。
英文:

Line of code in java codes to retrieve image path

jsonObject.getString("image"); // this is the path

My JSON file

  "image":"/Users/jz/Desktop/RwandanMeal/Omellete.jpg"
} ```

## Result in logcat

``` {
 "image":"\/Users\/jz\/Desktop\/RwandanMeal\/ugari.jpg"
} ```

As you see my path has been manipulated and it could be the reason 

</details>


# 答案1
**得分**: 1

Sure, here's the translation:

```java
jsonObject.getString("image").replace("\\", "");
英文:

Remove backslashes

jsonObject.getString(&quot;image&quot;).replace(&quot;\\&quot;,&quot;&quot;);

huangapple
  • 本文由 发表于 2020年9月24日 18:55:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/64044974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定