简体   繁体   English

Android:在条形码扫描仪构建器 window 上打印数据

[英]Android: print data on barcode scanner builder window

Ok, so i need to display some of my product's database data on the scanner builder window(as shown in the image) when this product gets scanned.好的,所以当该产品被扫描时,我需要在扫描仪构建器窗口(如图所示)上显示我产品的一些数据库数据。 Scanner window results扫描仪 window 结果

As you can see in the image, the barcode scanner is displayed, my question is: is it possible to print in this windows some other data except from the product's barcode?正如您在图像中看到的那样,显示了条形码扫描仪,我的问题是:是否可以在此 windows 中打印除产品条形码之外的其他数据? if yes how should i move?如果是,我应该如何移动?

this is my windows builder code这是我的 windows 构建器代码

public void handleResult(Result result) {
         //myResult= barcode text
         myResult = result.getText();
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Scan Result");
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                scannerView.resumeCameraPreview(addquantityactivity.this);
                updateData();
            }
        });
        builder.setNeutralButton("Visit(if url)", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myResult));
                startActivity(browserIntent);
            }
        });
        builder.setMessage(result.getText());
        AlertDialog alert1 = builder.create();
        alert1.show();

    }

Do you see where it says builder.setMessage(result.getText());你看到它在哪里说 builder.setMessage(result.getText()); <--? <--?

This is where you'd set the result.这是您设置结果的地方。 At the moment you're just putting in the result text which is the number.目前,您只需输入结果文本,即数字。 If you want something more, there is where you would put it.如果你想要更多的东西,你可以把它放在哪里。

EDIT:编辑:

I'm terrible at writing answers.我写答案很糟糕。 The method you are using is defined here .您使用的方法在此处定义。 It takes in a Character Sequence and will display it.它接受一个字符序列并将其显示出来。 Or it can take in an Int and show that.或者它可以接收一个 Int 并显示出来。

EDIT2:编辑2:

As an example of concatenating the barcode with some other information I would do this:作为将条形码与其他一些信息连接的示例,我会这样做:

String myMessage = result.getText() + " and some other amazing information about this barcode";

builder.setMessage(myMessage);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM