receive parameters from a listview

0

I have an activity that with a list of products, for each onclick that I do on each element of that list, sends 2 parameters in another activity to love another list according to the elements selected in the first list ... what I want do is a botton that allows me to see the list in the second activity .... without that second activity expects the 2 parameters. (I MUST MONSTER THE LIST NO MORE ...) there is my code ..

  case R.id.Carrito:
                String token=get.doInBackground().toString();
            TextView texto;
            texto = (TextView) view.findViewById(R.id.txtCodigo);
            String text2 = texto.getText().toString();
            Intent intent2 = null;intent2= new Intent(busqueda.this,Compra.class);
            intent2.putExtra("TOKENS", datas);
            intent2.putExtra("CODI", text2);
           // startActivity(intent2);
            Toast.makeText(busqueda.this,"Producto fue agregado...",Toast.LENGTH_LONG).show();
            return   super.onContextItemSelected(item);

There is the code of the second that receives and reads loo parametros ..

  protected String doInBackground(Void... params) {
        link = (TextView) findViewById(R.id.textView);
        code = (TextView) findViewById(R.id.textView2);
        prod = new ArrayList<>();
        lista_eligida = (ListView) findViewById(R.id.listView_eligida);
        final Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String linked = null;
        String coded = null;


        if (extras != null) {
            linked = extras.getString("TOKENS");
            coded = extras.getString("CODI");
        }
            // link.setText(linked);
            //code.setText(coded);
            String url = "http://www.air-intra.com/apps/air-app/agregar.php?token=" + linked + "&codiart=" + coded + "";
            HttpHandler sh = new HttpHandler();
            JSONObject jsonStr = sh.makeServiceCall(url);

            Log.e(TAG, "Response from url: " + jsonStr);
            try {
                JSONObject jsonObj = new JSONObject(String.valueOf(jsonStr));
                JSONArray contacts = jsonObj.getJSONArray("PRR");
                for (int i = 0; i < contacts.length(); i++) {
                    JSONObject c = contacts.getJSONObject(i);

                    String codig = c.getString("codigo");
                    String des = c.getString("descrip");
                    String prec = c.getString("precio");
                    // String garb = c.getString("fisicolug");

                    HashMap<String, String> contacto = new HashMap<>();

                    contacto.put("codigo", codig);
                    contacto.put("descrip", des);
                    contacto.put("precio", prec);
                    //contact.put("fisicolug", garb);

                    prod.add(contacto);

                }
            } catch (final JSONException e) {

            }


        return null;
    }
        @Override
        protected void onPostExecute (String result){
            if (pDialog.isShowing())
                pDialog.dismiss();
            super.onPostExecute(result);


            final ListAdapter adapter = new SimpleAdapter(Compra.this, prod,
                    R.layout.item_carrito, new String[]{"codigo", "descrip", "precio"},
                    new int[]{R.id.tvcode, R.id.tvdescrip, R.id.tvprec});
            lista_eligida.setAdapter(adapter);

            //registerForContextMenu(lista_eligida);
            //  registerForContextMenu(textView);

        }
    
asked by Wid Maer 27.06.2017 в 17:29
source

0 answers