zoukankan      html  css  js  c++  java
  • 二维码所有

    private TextView mTv_Ruslet;
    private EditText mInput;
    private ImageView mImg;
    private CheckBox isLogo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTv_Ruslet = (TextView) findViewById(R.id.tv_ruselt);
    mInput = (EditText) findViewById(R.id.et_text);
    mImg = (ImageView) findViewById(R.id.img);
    isLogo = (CheckBox) findViewById(R.id.is_logo);
    }
    //生成二维码
    public void make(View view){
    String input=mInput.getText().toString().trim();
    //生成二维码,然后为二维码增加logo
    Bitmap bitmap= EncodingUtils.createQRCode(input,500,500,isLogo.isChecked() ? BitmapFactory.decodeResource(getResources(),R.drawable.psb) : null
    );
    mImg.setImageBitmap(bitmap);
    }
    //扫描二维码
    public void scan(View view){
    startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class), 0);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode==RESULT_OK){
    Bundle bundle=data.getExtras();
    String result=bundle.getString("result");
    mTv_Ruslet.setText(result);
    mInput.setText(result);
    }else if(resultCode==RESULT_CANCELED){
    mTv_Ruslet.setText("扫描出错");
    }
    }
  • 相关阅读:
    设计模式详解(图码)
    设计模式详解(图)
    Zookeeper学习
    取消单元格的点击事件
    ios 中生成随机数
    IOS 时间和时间戳之间转化
    偏好存空判断
    限制textfield的文字长度
    tabBar的图标不被系统渲染
    (转)IOS http请求的get 和 post的请求的区别
  • 原文地址:https://www.cnblogs.com/zzwerzi/p/7638471.html
Copyright © 2011-2022 走看看