怎么接收这个方法返回的参数

y871625716 2017-07-19 12:01:20
public String getBarcode(Message msg){
String bar=msg.obj + "\n";
return bar;
}

public void GetInfo (View view) {
String barcode=this.getBarcode();
String url="http://192.168.16.128:8081/api/v1/marc/item/getinfos/"+barcode.toString();
xxxx
xxxx
xxxx
xxxx
}
这样会报错
'getBarcode(android.os.Message)' in 'com.android.barcodescandemo.MainDemo' cannot be applied to '()'

求大神解答怎么接收。

...全文
261 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
M义薄云天 2017-07-19
  • 打赏
  • 举报
回复
String barcode=this.getBarcode()里面怎么没传参数进去,你上面定义的方法里面有形参呀
y871625716 2017-07-19
  • 打赏
  • 举报
回复
我问的是参数写什么 public String getbarcode(Message msg){ String barcode=msg.obj+""; System.out.println("barcode " + barcode); Log.d("012","barcode " + barcode); return barcode; }
lyn584238910 2017-07-19
  • 打赏
  • 举报
回复
引用 2 楼 zc881124 的回复:
String barcode=this.getBarcode(); 需传Message参数。
你这样设置构造函数的目的是什么
青年卫大师 2017-07-19
  • 打赏
  • 举报
回复
编译都通不过
Neo_whl 2017-07-19
  • 打赏
  • 举报
回复
方法调用需要保持个数,数据类型,先后顺序一致,显然调用时漏写了参数
110成成 2017-07-19
  • 打赏
  • 举报
回复
String barcode=this.getBarcode(); 需传Message参数。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧