宝峰科技

 找回密码
 注册

QQ登录

只需一步,快速开始

智能终端设备维修查询系统注册会员邮箱认证须知!
查看: 534|回复: 0

[B4A 基础教程 原创] B4A 自定义返回为 Bitmap 类型的函数报错:Resumable subs return type must be ResumableSub (or none)

[复制链接]
  • TA的每日心情
    开心
    2021-10-8 11:02
  • 签到天数: 94 天

    [LV.6]常住居民II

    admin 发表于 2020-5-27 22:07:03 | 显示全部楼层 |阅读模式

    欢迎您注册加入!这里有您将更精采!

    您需要 登录 才可以下载或查看,没有帐号?注册

    x
    我们先来看下具体报错:

    Resumable subs return type must be ResumableSub

    Resumable subs return type must be ResumableSub


    经反复修改代码最终达到要求:
    [Visual Basic] 纯文本查看 复制代码
    Sub Globals
    	'These global variables will be redeclared each time the activity is created.
    	'These variables can only be accessed from this module.
    	
    	'例程说明:ListView控件加载本地图片及网络图片
    	
    	'定义 ListView1 变量
    	Private ListView1 As ListView
    	'Private Label1 As Label
    	
    	Private url As String = "https://www.wgbcw.com/data/attachment/common/e3/common_34_icon.png"
    End Sub
    
    Sub Activity_Create(FirstTime As Boolean)
    	'Do not forget to load the layout file created with the visual designer. For example:
    	'Activity.LoadLayout("Layout1")
    	
    	'加载布局
    	Activity.LoadLayout("LayListView")
    	
    	'设置ListView1控件的属性
    	'默认方式
    	ListView1.Left = 0
    	ListView1.Top  = 0
    	ListView1.Width = 100%x '宽设置为屏幕宽
    	ListView1.Height = 200dip
    	ListView1.AddSingleLine("ListView 单行文字演示")
    	'ListView1.Color = Colors.Blue
    	ListView1.AddSingleLine2("ListView 单行文字演示二",1)
    	ListView1.AddTwoLines("ListView 两行文字演示第一行","ListView 两行文字演示第二行")
    	ListView1.Height = 360dip
    	ListView1.AddTwoLines2("ListView 两行文字演示二第一行","ListView 两行文字演示二第二行",2)
    	ListView1.AddTwoLinesAndBitmap("ListView 控件使用例程第一行","ListView 两行文字带图片第二行默认一",LoadBitmap(File.DirAssets, "BFSoft.png"))
    	ListView1.AddTwoLinesAndBitmap2("ListView 控件使用例程第一行","ListView 两行文字带图片第二行默认二",LoadBitmap(File.DirAssets, "BFSoft.png"),3)
    	
    
    '	'加载网络图片,必须添加 OkHttpUtils2 类库
    '	Dim job As HttpJob
    '
    '	Dim Url As String = "https://www.wgbcw.com/data/attachment/common/e3/common_34_icon.png"
    '	
    '	job.Initialize("",Me)
    '	job.Download(Url)
    '	Wait For (job) JobDone(job As HttpJob)
    '	If job.Success Then
    '		'ListView1.SetBackgroundImage(m_httpjob.GetBitmap)
    '		ListView1.Height = 420dip
    '		ListView1.AddTwoLinesAndBitmap("ListView 加载网络图片演示","第二行",job.GetBitmap)
    '	End If
    '	job.Release
    
    	'把加载网页图片的用函数来实现
    	Dim bitmap As ResumableSub = LoadImage(url)
    	Wait for (bitmap) complete(Result As Bitmap)
    	'ListView1.SetBackgroundImage(job.GetBitmap)
    	ListView1.Height = 420dip
    	ListView1.AddTwoLinesAndBitmap("ListView 加载网络图片演示","第二行",Result)
    	'LoadImageTest
    End Sub
    
    '读取并加载网络图片函数
    'Main - 82: Resumable subs return type must be ResumableSub (or none).
    'Sub m_GetBitmap(Text1 As String) As Bitmap
    Sub LoadImageTest 
    	'Dim obj As Object = LoadImmage(Text1)
    	Dim bitmap As ResumableSub = LoadImage(url)
    	Wait for (bitmap) complete(Result As Bitmap)
    	Log(Result)
    '	If obj <> Null Then
    '		Dim bitmap As Bitmap = obj
    '		Return bitmap
    '	Else
    '		Return Null
    '	End If
    End Sub
    'Sub LoadImage(url As String) As Bitmap
    Sub LoadImage(Text1 As String) As ResumableSub
    	'加载网络图片,必须添加 OkHttpUtils2 类库
    	Dim job As HttpJob
    
    	job.Initialize("",Me)
    	job.Download(Text1)
    	Wait For (job) JobDone(job As HttpJob)
    	If job.Success Then
    		Dim bitamp As Bitmap = job.GetBitmap
    		
    		job.Release
    		Return bitamp
    		
    	End If
    	job.Release
    	Return Null
    End Sub


    本打算自定义 LoadImage 函数来加载网页图片返回 Bitmap 后传参数给ListView1.AddTwoLinesAndBitmap的第三个参数,但几经周折都报错,最终的代码已经达到要求了……

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    免责声明

    本站中所有被研究的素材与信息全部来源于互联网,版权争议与本站无关。本站所发布的任何软件编程开发或软件的逆向分析文章、逆向分析视频、补丁、注册机和注册信息,仅限用于学习和研究软件安全的目的。全体用户必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。学习编程开发技术或逆向分析技术是为了更好的完善软件可能存在的不安全因素,提升软件安全意识。所以您如果喜欢某程序,请购买注册正版软件,获得正版优质服务!不得将上述内容私自传播、销售或者用于商业用途!否则,一切后果请用户自负!

    点击这里给我发消息|Archiver|手机版|小黑屋|联系我们|宝峰科技网 ( 滇公网安备 53050202000040号 | 滇ICP备09007156号-2 )

    Copyright © 2001-2022, Tencent Cloud. GMT+8, 2021-10-21 04:37 , File On Powered by Discuz! X3.49

    快速回复 返回顶部 返回列表