zxing扫描结果为什么不显示

tankgoing 2017-11-08 05:08:14
新手。纯新手。上手1个礼拜。。。请大神看看
mainactivity

package com.gmhcash.android;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import com.google.zxing.client.android.CaptureActivity;


public class MainActivity extends AppCompatActivity {

EditText edt;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onScanner( View v)
{
Intent it=new Intent(this,CaptureActivity.class);
startActivityForResult(it,0);
}

public void onActivityResult(int requestCode,int resultCode,Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode==RESULT_OK)
{
Bundle bundle = data.getExtras();
String result = bundle.getString(CaptureActivity.SCANRESULT);
edt.setText(result);
}
}

}


然后是layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.gmhcash.android.MainActivity">

<EditText
android:id="@+id/edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="请扫码或输入订单号"
android:inputType="textPersonName"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:onClick="onScanner"
android:text="扫码"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:onClick="gotoOrderInfoActivity"
android:text="下一步"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</android.support.constraint.ConstraintLayout>


扫是可以扫 扫了没扫码反应 EditText不显示什么 试了1天没试出来为什么
...全文
235 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
雨焰 2017-11-10
  • 打赏
  • 举报
回复
有没有logcat提醒?或者摄像头权限有没有打开之类的
tankgoing 2017-11-08
  • 打赏
  • 举报
回复
有没有大神来看看哈
    本课程分享对由中国开发者提供的OpenCV条形码识别模块的原理和代码精讲。该模块借鉴“目标识别”领域先进理念,采用“定位-识别”二段模式,有效提高了自然环境下条码识别的准确率并保持了C++代码的高速度,相比较常用的zxing和zbar在准确率和识别速度上均有较大优势。更难得可贵的是在代码的实现过程中能够注意细节,在诸如“循环测试确定参数数值”“积分图的使用”“倾斜矩形纠偏”等处,均提供了思路清晰、弹性高的优质代码。作为一套通过了OpenCV官方的代码检验、解决一个常用领域内具体问题的模块,对于图像处理学习来说是难得可贵的。    逐条进行代码解读繁琐且低效,个人认为,在图像处理领域,能够运行和修改观察的代码对于学习研究至关重要。在理论剖析部分,也是由应用引导原理。同时做好知识的迁移和代码的复用工作。在这个过程中,创建针对性的实验非常重要。 课程内容分为4个部分:一是基本配置,包括· 条形码识别模块的安装使用 (cmake配置和OpenCV编译);· 构建用于测试和代码阅读的环境;· 模块对官方数据集的测试;二是条码定位,将详细讲解思路、原理和实现知识迁移部分将简单说一下在毛发识别上的迁移:三是条码识别,该部分内容会首先梳理框架,而后具体进行分析讲解    此外,我们将结合例子,将OpenCV的基础功能,包括积分图像、形态学变化、联通区域、透视变化等进行复习,加深理解。 

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧