如何在Android中的Edittext中显示扫描值 [英] How Do I Show The Scanned Values In An Edittext In Android

查看:345
本文介绍了如何在Android中的Edittext中显示扫描值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我以前用来干净扫描值的代码。我需要在单独的editText中显示每个值。

此代码打开扫描仪

this i the code i used to just toast the scanned values. i need to show each values in separate editText.
this code opens a scanner

public void onClick(View v) {
			// TODO Auto-generated method stub
			detailList(v);
			try {
	             //start the scanning activity from the com.google.zxing.client.android.SCAN intent

        Intent intent = new Intent(ACTION_SCAN);

        intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

        startActivityForResult(intent, 0);
} catch (ActivityNotFoundException anfe) {

        //on catch, show the download dialog

        showDialog(Primary.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();

    }

}
		});
}

and this is where i need help, to show the scanned values in editText

<pre lang="java">
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

        if (requestCode == 0) {

            if (resultCode == RESULT_OK) {

                //get the extras that are returned from the intent

                String contents = intent.getStringExtra("SCAN_RESULT");

                String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                Toast toast = Toast.makeText(this, "Content:" + contents + " Format:" + format, Toast.LENGTH_LONG);

                toast.show();

            }

        }

推荐答案

与添加任何文字的方式相同到EditText控件。如果您不确定使用哪种方法或属性,请快速查看文档 [< a href =http://developer.android.com/reference/android/widget/EditText.html\"target =_ blanktitle =New Window> ^ ]应该有所帮助。
The same way you would add any text to an EditText control. If you are not sure which method or property to use then a quick look at the documentation[^] should help.


这篇关于如何在Android中的Edittext中显示扫描值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆