mercredi 20 janvier 2016

how get responce valuve when click checkbox and set another button

hey guys i am warking an app where using a checkbox and when checkbox is clicked then i am getting an JSON response

i want to get that response value and checked response in other button clicked Please help me i am also use sharedpreference an intent and declare globally but i am getting null value

my code for checkbox

_CheckBox = (CheckBox) findViewById(R.id.check_wallet);
    _CheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
            if (isChecked == true) {
                promolayout.setVisibility(View.GONE);
                _Service_amount.setVisibility(View.GONE);
                SlideToAbove();
                isBottom = false;
                StringRequest postRequest = new StringRequest(Request.Method.POST, url,
                        new Response.Listener<String>() {
                            @Override
                            public void onResponse(String response) {
                                try {
                                    JSONObject json_Response = new JSONObject(response);
                                    String _RchAmount = json_Response.getString("pay_from_wallet");
                                    String _Remainbalance = json_Response.getString("ewalletbalance");
                                    String _InrPay = json_Response.getString("amt_collected");         // want to check this to other button 
                                    confirm_payWallet.setText("Pay from eWallet Rs. " + _RchAmount);
                                    confirm_TotalWallet.setText("Your current ewallet balance is Rs." + _Remainbalance);
                                    total_pay.setText("Rs. " + _InrPay);
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                                Log.d("checked in ewallet", "------>" + response);
                            }
                        },
                        new Response.ErrorListener() {
                            public void onErrorResponse(VolleyError error) {
                                Log.e("Checked err error==", "===>" + error);
                                error.printStackTrace();
                            }
                        }) {
                    protected Map<String, String> getParams() {
                        MyApplication uid = (MyApplication) getApplicationContext();
                        String user = uid.getuser();
                        MyApplication _tansId = (MyApplication) getApplicationContext();
                        String trans_id = _tansId.getTransaction();
                        Map<String, String> params = new HashMap<>();
                        params.put("userid", user);
                        params.put("transid", trans_id);
                        params.put("ewallet_checkbox", "on");
                        Log.i(TAG, "Sending Value" + params);
                        return params;
                    }
                };
                newApp.getInstance().addToRequestQueue(postRequest);
                }

and want to checkvalue in this button

_PayNow = (Button) findViewById(R.id.confirm_paynow);
    _PayNow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {                          // here
            Intent payIntent = getIntent();
            String full_pay =payIntent.getStringExtra("fullpay");
            Toast.makeText(getApplicationContext(), "last Amount is ="+full_pay, Toast.LENGTH_LONG).show();
            StartPayment runner = new StartPayment();
            runner.execute();
        }
    });

note : these two method in same class

thanks




Aucun commentaire:

Enregistrer un commentaire