如何使代码在真实服务器上工作,Glide在Real Server上不适合我

发布于 2025-01-27 07:19:09 字数 1735 浏览 3 评论 0原文

我在Android编程方面几乎没有经验,所以我转向您。事实是,我为自己创建了一个程序来练习自己的技能。现在,我有一个listView,ListView有一个imageView和一个文本视图,可以通过适配器成功填充。在ImageView上,我从服务器中获得了一张图片,问题是当服务器是本地的,所有内容都可以正常工作,但是如果真实的服务器,则图片不会加载。

url =“ http://192.168.0.1/image/”或url =“ http:// mysite/image/”

view = inflter.inflate(R.layout.list_item, null);
final ImageView icon = (ImageView) view.findViewById(R.id.GoodsIcon);

    try {
       Glide.with(url+GoodsList[i].GOODS_MEDIUM_IMAGE_NAME).into(icon);
    } catch (Resources.NotFoundException e) {
       Toast.makeText(view.getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }

尝试catch 即使服务器是真实的,也不会捕获错误。

<ImageView
    android:id="@+id/GoodsIcon"
    android:layout_width="100dp"
    android:layout_height="130dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="0dp"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="2dp"
    android:adjustViewBounds="true"
    android:fontFamily="@font/bebas_neue_light"
    android:scaleType="fitEnd" />

在清单中,我已经添加了所有访问权限。

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

注意:我还从服务器上拿起文本文本,即使在真实服务器上,文本也成功加载

I have little experience in programming for android, so I turn to you. The fact is that I created a program for myself to practice my skills. Right now I have one ListView and the ListView has one ImageView and a TextView to fill in successfully through an Adapter. On ImageView I get a picture from the server, the problem is that when the server is local everything works fine, but if the real server then the picture does not load.

url="http://192.168.0.1/image/" or url="http://mysite/image/"

view = inflter.inflate(R.layout.list_item, null);
final ImageView icon = (ImageView) view.findViewById(R.id.GoodsIcon);

    try {
       Glide.with(url+GoodsList[i].GOODS_MEDIUM_IMAGE_NAME).into(icon);
    } catch (Resources.NotFoundException e) {
       Toast.makeText(view.getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }

try catch does not catch errors, even when the server is real.

<ImageView
    android:id="@+id/GoodsIcon"
    android:layout_width="100dp"
    android:layout_height="130dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="0dp"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="2dp"
    android:adjustViewBounds="true"
    android:fontFamily="@font/bebas_neue_light"
    android:scaleType="fitEnd" />

In the manifest I have already added all access.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Notes: I also take the text for the TextView from the server, even on the real server the text loads successfully

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文