private void init() { this.btAdd = (Button) findViewById(R.id.btAdd); this.etNombre = (EditText) findViewById(R.id.etNombre); this.etInstruccion = (EditText) findViewById(R.id.etInstruccion); this.img = (ImageView) findViewById(R.id.iv); this.lv = (ListView) findViewById(R.id.lvAlta); this.rg = (RadioGroup) findViewById(R.id.radiogroup); this.rbCarne = (RadioButton) findViewById(R.id.rbCarne); this.rbPescado = (RadioButton) findViewById(R.id.rbPescado); this.rbPostre = (RadioButton) findViewById(R.id.rbPostre); this.lvu = (ListView) findViewById(R.id.lvUtensilios); btAdd = (Button) findViewById(R.id.btElegir); listaingre = new ArrayList<>(); gp = new GestorReceta(this); gpi = new GestorIngrediente(this); gri = new GestorRecetaIngrediente(this); gpu = new GestorUtensilio(this); r = new Receta(); r.setNombre(getIntent().getExtras().getString("nombre")); r.setFoto(getIntent().getExtras().getString("foto")); r.setId_categoria(getIntent().getExtras().getLong("cat")); r.setInstrucciones(getIntent().getExtras().getString("instrucciones")); r.setId(getIntent().getExtras().getLong("id")); img.setImageURI(Uri.parse(r.getFoto())); etNombre.setText(r.getNombre()); etInstruccion.setText(r.getInstrucciones()); gpi.open(); c = gpi.getCursor(); adp = new AdaptadorIngredientes(this, c); lv.setAdapter(adp); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tostada(c.getString(1) + " ha sido añadido"); listaingre.add(c); } }); gpi.close(); gpu.open(); c2 = gpu.getCursor(); adpu = new AdaptadorUtensilios(this, c2); lvu.setAdapter(adpu); lvu.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {} }); gpu.close(); }
@Override protected void onPause() { super.onPause(); gpi.close(); gp.close(); gri.close(); Log.v("APLICACION", "Resume Alta Close"); }