help, I try to update by selecting a value of a spinner which I want to eliminate by means of its id

0

What I try is to select a value of the spinner and in the edittext to put the update. This is already done but not with the value I am selecting, I update the value with an id before the one I am selecting.

   // ACTUALIZAR FAMILIA
  private void submitForm() {
    int type = 
 Integer.parseInt(spbuscarfamilia.getSelectedItem().toString());
    ActualizarFamilia(
            spbuscarfamilia.getItemIdAtPosition(type),
            etmodificacion.getText().toString());
 }

private void ActualizarFamilia(final long id, final String familia) {
    // Tag used to cancel the request
    String cancel_req_tag = "register";
    showLoadingDialog("Espere Actualizando ......");

    StringRequest strReq = new StringRequest(Request.Method.POST,
            Config.URL_UPDATE_FAMILIA, 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(updateFamilia.this," Actualización  en Familia  con  éxito",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();
                    Limpiar();
                } else {
                    hideLoadingDialog();
                    Toast toast2= Toast.makeText(updateFamilia.this,"No 
se Actualizó  por que no existe  Familia 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();
                    Limpiar();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }, new Response.ErrorListener() {

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


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

}

public void hideLoadingDialog() {
    try {
        if (progressDialog != null) {
            progressDialog.dismiss();
        }
    } catch (Exception a) {
        progressDialog = null;
    }
}
    
asked by Sofia 13.10.2017 в 17:06
source

0 answers