使用第三方开源库Glide加载网络图片
Image image = (Image) findComponentById(ResourceTable.Id_image);Uri uri =Uri.parse("https://c-ssl.duitang.com/uploads/blog/202105/21/20210521205533_613b9.jpg");Glide.with(getContext()).load(uri).into(image);
完整代码:
build.gradle中添加依赖implementation 'io.openharmony.tpc.thirdlib:glide:1.1.2'完整加载图片代码
public class MainAbilitySlice extends AbilitySlice { @Override public void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_main_net); Image image = (Image) findComponentById(ResourceTable.Id_image); Uri uri =Uri.parse("https://c-ssl.duitang.com/uploads/blog/202105/21/20210521205533_613b9.jpg"); Glide.with(getContext()).load(uri).into(image); }}完整源代码
https://gitee.com/hspbc/harmonyos_demos/tree/master/imageDemo
花粉社群VIP加油站
猜你喜欢