繁体   English   中英

在 Android 中通过 Intent 使用 Zxing 扫描条码时如何更改文本?

[英]How to change text when scanning barcodes with Zxing via intent in Android?

通过意图启动条码扫描器(zxing)时,是否可以更改提示文本“将条码放入取景器内......”?

Intent intent = new Intent("com.google.zxing.client.android.SCAN")

我想要用我的语言提示,我应该怎么做?

是的,简单明了:

intent.putExtra("PROMPT_MESSAGE", "Your Text Here");

如果它对任何人都有价值,那么如果您决定将 ZXings 库导入 Android Studio,您可以通过以下方式使用 IntentIntegrator 执行此操作:

integrator.addExtra("PROMPT_MESSAGE", "Your message here");

开发商在这里。 不,对不起,你不能那样做。 但是是的,如果你的意思是你想贡献一个新的翻译,请把文本发给我们。

它在我的 Android 上显示为“Positionieren Sie den Barcode innerhalb des Rechtecks”。 所以我想,文本取决于手持设备的区域设置(因为 ZXing 不提供在本地更改区域设置的设置)。

因此,如果您需要对现在不受支持的语言的支持,我敢打赌您必须与 ZXings 开发团队联系。

正确和现代的方法是

IntentIntegrator scanIntent = new IntentIntegrator(this);
scanIntent.setPrompt("TEXT THAT YOU WANT TO SHOW");

这项工作非常完美,因为我正在使用它 integrator.setPrompt("Here your text");

然后......当你点击(意味着结果......)你可以改变提示重试或继续......以这种方式:

builder.setTitle("Scan Result");
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
          // here your new intent or other...like blabla();
    }
}).setNegativeButton("Retry",new  DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
         //even here new itent like  blablabla();
    }

暂无
暂无

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

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