如何使代码在真实服务器上工作,Glide在Real Server上不适合我
我在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论