在我的Android应用程序中集成qr扫描仪..工作正常..在我的Android应用程序中显示扫描结果形式吐司...但不是我想在文本框中显示扫描结果...任何人都可以帮助我
答案 0 :(得分:1)
TextViewName.setText(ResultText);
答案 1 :(得分:0)
以下代码可以正常工作在textview中显示条形码阅读器结果但我无法在微调器中显示条形码阅读器结果......
public class SpinnerEx4Activity extends AppCompatActivity {
public static final String BARCODE_KEY = "BARCODE";
Spinner s1, s2, s3, s4;
private Barcode barcodeResult;
private Barcode spinner3;
private Button button3;
TextView tex, tex1, result1;
DatabaseHandler dbhndlr;
Cursor spinner1csr, spinner2csr, spinner3csr, spinner4csr, search;
SimpleCursorAdapter sca, sca2, sca3, sca4, sca6;
long spinner1_selected = 0;
CheckBox ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spinner_ex4);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final Button button2 = (Button) findViewById(R.id.button2);
result1 = (TextView) findViewById(R.id.barcodeResult);
assertNotNull(result1);
s1 = (Spinner) findViewById(R.id.spinner8);
s2 = (Spinner) findViewById(R.id.spinner7);
s3 = (Spinner) findViewById(R.id.spinner3);
dbhndlr = new DatabaseHandler(this);
final Button button3 = (Button) findViewById(R.id.button3);
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startScan();
}
});
if (savedInstanceState != null) {
Barcode restoredBarcode = savedInstanceState.getParcelable(BARCODE_KEY);
if (restoredBarcode != null) {
result1.setText(restoredBarcode.rawValue);
barcodeResult = restoredBarcode;
}
}
private void startScan() {
final MaterialBarcodeScanner materialBarcodeScanner = new MaterialBarcodeScannerBuilder()
.withActivity(SpinnerEx4Activity.this)
.withEnableAutoFocus(true)
.withBleepEnabled(true)
.withBackfacingCamera()
.withCenterTracker()
.withText("Scanning...")
.withResultListener(new MaterialBarcodeScanner.OnResultListener() {
@Override
public void onResult(Barcode barcode) {
spinner3 = barcode;
result1.setText(barcode.rawValue);
}
})
.build();
materialBarcodeScanner.startScan();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putParcelable(BARCODE_KEY, barcodeResult);
super.onSaveInstanceState(outState);
}