InformáticaBásico1 respuestas

Alguien podria ayudarme con este Codigo tengo que crear una Aplicacion en Eclipse que muestreuna lista de Postres y al momento de seleccionar uno en otra lista (Spinners) muestre sus derivados del pos?

Alguien podria ayudarme con este Codigo tengo que crear una Aplicacion en Eclipse que muestre una lista de Postres y al momento de seleccionar uno en otra lista (Spinners) muestre sus derivados del postre seleccionado. Y al dar Click mostrara sus Ingredientes solo me muestra los ingredientes del Primero ya que en los demas repite lo mismo. Package com. Menudepostres ; import android. Os. Bundle ; import android. App. Activity ; import android. View. Menu ; import android. View. View ; import android. Widget. AdapterView ; import android. Widget. AdapterView. OnItemSelectedListener ; import android. Widget. ArrayAdapter ; import android. Widget. Spinner ; import android. Widget. TextView ; public class MainActivity extends Activity implements OnItemSelectedListener{ Spinner spPostres, spSubpostres ; / / ADAPTADOR PARA LAS DISTINTAS OPCIONES / / ArrayAdapter ssPostres, ssPastel, ssGelatina, ssFlanes, ssGalletas, ssFrappes, ssChamoyadas, ssLimpiar ; String[] opcPostres = new String[]{"Pastel", "Gelatina", "Flanes", "Galletas", "Frappes", "Chamoyadas"} ; / / SUBPOSTRES / / String[] opcPastel = new String[]{"Chocolate", "Imposible", "Sencillo"} ; String[] opcGelatina = new String[]{"Leche", "Agua", "Nose"} ; String[] opcFlanes = new String[]{"Flan de Coco", "Flan de Vainilla", "Sencillo"} ; String[] opcGalletas = new String[]{"Chocolate", "Vainilla", "Espolvoreadas"} ; String[] opcFrappes = new String[]{"Cafe", "nose", "Nose"} ; String[] opcChamoyadas = new String[]{"Fresa", "Mango", "Chamoy"} ; / / OPCION LIMPIAR SE INICIALIZA EN 0 PUESTO QUE NO LLEVA NADA / / String[] Limpiar = new String[0] ; / / SE DECLARA UN CAMPO DE TEXTO DE TIPO TEXT VIEW DONDE APARECERA LOS INGREDIENTES SELECCIONADOS / / TextView tv1 ; @Override protected void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState) ; setContentView(R. Layout. Activity_main) ; / / RELACIONAMOS LAS VARIABLES DECLARADAS CON SUS "ID" / / spPostres = (Spinner)findViewById(R. Id. spPostres) ; spSubpostres = (Spinner)findViewById(R. Id. spTipos) ; tv1 = (TextView) findViewById(R. Id. textView1) ; / / DICHAS VARIABLES LAS MANDAMOS A LLAMAR CON ESTOS METODOS QUE SON LISTAS QUE MANDAN A LLAMAR A OTRA LISTA : O / / spPostres. SetOnItemSelectedListener(this) ; spSubpostres. SetOnItemSelectedListener(this) ; / / PERO DE NADA SIRVE e_e SI LOS ADAPTADORES NO LOS RELACIONAMOS CON SUS RESPECTIVOS "STRINGS" / / ssPostres = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcPostres) ; ssPastel = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcPastel) ; ssGelatina = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcGelatina) ; ssFlanes = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcFlanes) ; ssGalletas = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcGalletas) ; ssFrappes = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcFrappes) ; ssChamoyadas = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, opcChamoyadas) ; ssLimpiar = new ArrayAdapter (this, android. R. layout. Simple_spinner_item, Limpiar) ; spPostres. SetAdapter(ssPostres) ; } / / PFF ESO SOLO ERA PARTE DE LA DECLARACION : ( VAMOS A EMPEZAR A PROGRAMAR SALUDOS PROFE CRISTHIAN SI VE ESTO NUESTRAS OJERAS SON GRACIAS A USTED / / @Override public boolean onCreateOptionsMenu(Menu menu) { / / Inflate the menu ; this adds items to the action bar if it is present. GetMenuInflater(). Inflate(R. Menu. Main, menu) ; return true ; } @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg) { / / TODO Auto - generated method stub / / INICIAMOS EL SPINNER POSTRES / / switch(arg0. GetId()){ case R. Id. spPostres : int seleccionado = spPostres. GetSelectedItemPosition() ; / / CREAMOS UNA VARIABLE SELECCIONADO / / if(seleccionado = = 0){ spSubpostres. SetAdapter(ssPastel) ; } if(seleccionado = = 1){ spSubpostres. SetAdapter(ssGelatina) ; } if(seleccionado = = 2){ spSubpostres. SetAdapter(ssFlanes) ; } if(seleccionado = = 3){ spSubpostres. SetAdapter(ssGalletas) ; } if(seleccionado = = 4){ spSubpostres. SetAdapter(ssFrappes) ; } / / SUBPOSTRES / / case R. Id. spTipos : int seleccionado1 = spSubpostres. GetSelectedItemPosition() ; if(seleccionado1 = = 0){ tv1. SetText("3 Huevos, Medio Kilo de Harina, Mantequilla, Polvo para Hornear ") ; } if(seleccionado1 = = 1){ tv1. SetText("Un litro de leche, medio kilo de Harina, Chocolate previo a Baño Maria") ; } if(seleccionado1 = = 2){ tv1. SetText("Fresa, Mango o frutas al gusto. ") ; } int seleccionado2 = spSubpostres. GetSelectedItemPosition() ; / / GELATINA if(seleccionado2 = = 3){ tv1. SetText("Primero de Gelatina") ; } if(seleccionado2 = = 4){ tv1. SetText("Segundo de Gelatina") ; } if(seleccionado2 = = 5){ tv1. SetText("Tercero de Gelatina") ; } } } @Override public void onNothingSelected(AdapterView arg0) { / / TODO Auto - generated method stub } }.

8Daviinzonperez

En resumen

Bcxccxffdcxfdfdcxfcdfx gongo oye en insta me llamo antonio_ps4.

Mejor respuesta

Nirvana96

2

Bcxccxffdcxfdfdcxfcdfx gongo oye en insta me llamo antonio_ps4.