如何生成5个以上数据信息的QR码?



问题是当我试图把我的字符串在qrgEncoder =新的qrgEncoder它总是错误的我知道它错了,因为我需要把我所有的字符串在一个单一的字符串或哈希,但我不知道如何把我的哈希!非常感谢您的回复,先生,谢谢您的预付款

firstname = findViewById(R.id.firstname);
phone = findViewById(R.id.phone);
address = findViewById(R.id.address);
qr = findViewById(R.id.qr);
btn = findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String first = firstname.getText().toString().trim();
String phones = phone.getText().toString().trim();
String textaddress = address.getText().toString().trim();
if(first.length() > 0 || phones.length() > 0 || textaddress.length() > 0) {
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
display.getSize(point);
int width = point.x;
int height = point.y;
int smallerDimension = width < height ? width : height;
smallerDimension = smallerDimension * 3 / 4;
qrgEncoder = new QRGEncoder(
first,phones,textaddress, null,
QRGContents.Type.TEXT,
smallerDimension);
try {
bitmap = qrgEncoder.encodeAsBitmap();
qr.setImageBitmap(bitmap);
} catch (WriterException e) {
Log.v(TAG, e.toString());
}
}
}
});
}

}

如果我看看你的代码和QRGEncoder是如何实现的,我猜你需要先连接你的字符串输入,然后再添加到它的构造函数中。

因此,你应该这样调用它:

StringBuilder qrParam = new StringBuilder();
qrParam.append(first);
qrParam.append(phones);
qrParam.append(textaddress);
qrgEncoder = new QRGEncoder(
qrParam.toString(),
null,
QRGContents.Type.TEXT,
smallerDimension);

相关内容

  • 没有找到相关文章

最新更新