I need to increase and save a value that I get from an edittext in android studio

2

Codig (JAVA) to increase the value Existence in my database In this part where I want to increase the value of Existence and save your update is where I have the error.

The LogCat shows me the error here.etExistence.setText (count);

 private void submitForm() {
    count= Integer.parseInt(etExistencia.getText().toString());
    count++;
    etExistencia.setText(count);

    UpdateExistencia(
            etNumeroParte.getText().toString(),
            etExistencia.getText().toString()
    );
}

private void UpdateExistencia(final String NumeroParte, final String Existencia) {
    // Tag used to cancel the request
    String cancel_req_tag = "register";
    showLoadingDialog("Por  Favor espere....Actualizando ....");

    StringRequest strReq = new StringRequest(Request.Method.POST,
            Config.URL_UPDATE_CONTADOR_EXISTENCIA_PROD, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            Log.d(TAG, "Register Response: " + response.toString());

            try {
                hideLoadingDialog();
                JSONObject jObj = new JSONObject(response);
                String estado = jObj.getString("estado");

                if (estado.equalsIgnoreCase("1")) {
                    Toast toast1= Toast.makeText(Movimiento.this,"Actualización correcta",Toast.LENGTH_LONG);
                    TextView v=(TextView)toast1.getView().findViewById(android.R.id.message);
                    v.setShadowLayer(0,0,0,Color.YELLOW);
                    v.setBackgroundColor(Color.GREEN);
                    v.setTextColor(Color.BLACK);
                    v.setTextSize(20);
                    toast1.setGravity(Gravity.CENTER|Gravity.CENTER,0,0);
                    toast1.show();
                } else {
                    hideLoadingDialog();

                    Toast toast2= Toast.makeText(getApplicationContext(), "No existe  Número de Parte  con este ID", Toast.LENGTH_LONG);
                    TextView v=(TextView)toast2.getView().findViewById(android.R.id.message);
                    v.setShadowLayer(0,0,0,Color.YELLOW);
                    v.setBackgroundColor(Color.RED);
                    v.setTextSize(20);
                    toast2.setGravity(Gravity.CENTER|Gravity.CENTER,0,0);
                    toast2.show();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, "Registration Error: " + error.getMessage());
            Toast.makeText(getApplicationContext(),
                    error.getMessage(), Toast.LENGTH_LONG).show();
            hideLoadingDialog();
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            // Posting params to register url
            Map<String, String> params = new HashMap<String, String>();
            params.put("NumeroParte",NumeroParte);
            params.put("Existencia",Existencia);
            return params;
        }
    };
    // Adding request to request queue
    AppSingleton.getInstance(getApplicationContext()).addToRequestQueue(strReq, cancel_req_tag);
}


public void showLoadingDialog(String texto) {
    try {
        if (loading == null) {
            loading = new ProgressDialog(this);
        }
        loading.setIndeterminate(true);
        loading.setCancelable(false);
        loading.setMessage(texto);
        loading.show();
    } catch (Exception exception) {
        loading = null;
    }
}

public void hideLoadingDialog() {
    try {
        if (loading != null) {
            loading.dismiss();
        }
    } catch (Exception a) {
        loading = null;
    }
}

THE ERROR THAT SHOWS ME WHEN I EXECUTE MY PROJECTOR IS IN THIS PART

etExistence.setText (count);

This is the error thrown by the LogCat.

  

01-23 22: 45: 33.157 9939-9939 / com.example.aceraspire.fujitsu_mysql   E / AndroidRuntime: FATAL EXCEPTION: main                                                                                       Process: com.example.aceraspire.fujitsu_mysql, PID: 9939                                                                                       android.content.res.Resources $ NotFoundException: String resource ID   0x1                                                                                           at android.content.res.Resources.getText (Resources.java:331)                                                                                           at   android.support.v7.widget.ResourcesWrapper.getText (ResourcesWrapper.java:52)                                                                                           at android.widget.TextView.setText (TextView.java:4554)                                                                                           at   com.example.aceraspire.fujitsu_mysql.Movimiento.submitForm (Movimiento.java:213)                                                                                           at   com.example.aceraspire.fujitsu_mysql.Movimiento.access $ 100 (Movimiento.java:34)                                                                                           at   com.example.aceraspire.fujitsu_mysql.Movement $ 2.onKey (Movimiento.java:93)                                                                                           at android.view.View.dispatchKeyEvent (View.java:9876)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1667)                                                                                           at   com.android.internal.policy.DecorView.superDispatchKeyEvent (DecorView.java:403)                                                                                           at   com.android.internal.policy.PhoneWindow.superDispatchKeyEvent (PhoneWindow.java:1800)                                                                                           at android.app.Activity.dispatchKeyEvent (Activity.java3021)                                                                                           at   android.support.v7.app.AppCompatActivity.dispatchKeyEvent (AppCompatActivity.java:543)                                                                                           at   android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent (WindowCallbackWrapper.java:53)                                                                                           at   android.support.v7.app.AppCompatDelegateImplBase $ AppCompatWindowCallbackBase.dispatchKeyEvent (AppCompatDelegateImplBase.java:315)                                                                                           at   com.android.internal.policy.DecorView.dispatchKeyEvent (DecorView.java:317)                                                                                           at   android.view.ViewRootImpl $ ViewPostImeInputStage.processKeyEvent (ViewRootImpl.java:4327)                                                                                           at   android.view.ViewRootImpl $ ViewPostImeInputStage.onProcess (ViewRootImpl.java:4298)                                                                                           at   android.view.ViewRootImpl $ InputStage.deliver (ViewRootImpl.java:3849)

    
asked by Sofia 24.01.2018 в 00:11
source

1 answer

0

The error is:

  

Resources $ NotFoundException: String resource ID # 0x1 at   android.content.res.Resources.getText (Resources.java:331)

You must convert the value you want to use to String since if you use an integer the system will try to find a resource in your application:

 etExistencia.setText(count); //* INCORRECTO!

converts to String the value of count , example:

etExistencia.setText(String.valueOf(count));

or otherwise:

etExistencia.setText(""+count);
    
answered by 24.01.2018 / 00:58
source