Inventory with Android [closed]

3

I'm trying to create an app to control product type an inventory, in case the user selects in RadioButton product and then with scanner will read the serial of the equipment.

The scanner is working, but the RadioButton and inventory list options are not working. I was based on the Renato Mattos code and will save the information in the DB. Follow the code.

package com.blogspot.wellingtonmiyake.radiobutton;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    EditText txtNome, txtIdade;
    TextView txtResultado, contextTxt;
    RadioGroup radioGroupInf;
    Button btnok, btnCapture;


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

        txtNome = (EditText) findViewById(R.id.txtNome);
        txtIdade = (EditText) findViewById(R.id.txtCode);
        contextTxt = (TextView) findViewById(R.id.scan_content);

        txtResultado = (TextView) findViewById(R.id.txtResultado);
        radioGroupInf = (RadioGroup) findViewById(R.id.radioGroupInf);

        btnCapture = (Button) findViewById(R.id.btnCapture);
        final Activity activity = this;
        btnCapture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //IntentIntegrator integrator = new IntentIntegrator(activity);
                //integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
                IntentIntegrator integrator = new IntentIntegrator(activity);

                integrator.setPrompt("CAMERA SCAN");
                integrator.setCameraId(0);
                integrator.initiateScan();
            }
        });

        btnok = (Button) findViewById(R.id.btnok);
        btnok.setOnClickListener(this);

        String nome = txtNome.getText().toString();
        String idade = txtIdade.getText().toString();
       // String scan = contextTxt.getText().toString();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if (result != null) {
            if (result.getContents() != null ){
                //String resultContents = result.getContents();
                contextTxt.setText("scan"+result);
                alert (result.getContents());
            }else{
                //alert ("Scan Cancelado");
                Toast toast = Toast.makeText(getApplicationContext(),
                        "No scan data received!", Toast.LENGTH_SHORT);
                toast.show();
            }

        } else {

            super.onActivityResult(requestCode, resultCode, data);
        }
    }
    private  void alert(String msg){
        Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_LONG).show();
    }

    @Override
    public void onClick(View v) {
    String imprimir = "Teste de botão radio" ;




        if(radioGroupInf.getCheckedRadioButtonId() != -1){
           RadioButton  selecao = (RadioButton) findViewById(radioGroupInf.getCheckedRadioButtonId());
            imprimir += "" +selecao.getText().toString();

        }

        txtResultado.setText(imprimir +txtNome.getText()+txtIdade.getText()+contextTxt.getText());
    }

   }
    
asked by anonymous 27.10.2017 / 15:03

0 answers