I hope you can support me with this doubt, however much I look for I can not find a way to replace the value I have in a textview
that is inside a table depending on what is selected in a spinner
.
Note: The table is generated according to the size of a list.
table = (TableLayout) view.findViewById(R.id.tabla);
for( int i = 0; i<frutasListaa.size(); i++){//filas frutasListaa.get(i).getIdequivalente2()+
lista.add(frutasListaa.get(i).getAlimento()+" "+frutasListaa.get(i).getCantidad()+" "+frutasListaa.get(i).getUnidad()+" = "+frutasListaa.get(i).getCalorias()+" kcal");
//--------------TABLAAAA ----------------------//
TableRow tableRow = new TableRow(getContext());//frutasListaa.get(i).getIdTbalimentos()+
table.addView(tableRow);
tvAlimentos = new TextView(getContext());
tvPorcion = new TextView(getContext());
tvCalorias = new TextView(getContext());
tvAlimentos.setText(frutasListaa.get(i).getAlimento());
tableRow.addView(tvAlimentos);
tvPorcion.setText(" "+frutasListaa.get(i).getCantidad()+" "+frutasListaa.get(i).getUnidad());
tableRow.addView(tvPorcion);
tvCalorias.setText(" "+frutasListaa.get(i).getCalorias());
tableRow.addView(tvCalorias);
}
The following is a spinner:
ArrayAdapter<CharSequence> spinnerAdapter=new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, lista);
spdesayuno1.setAdapter(spinnerAdapter);
The layout is as follows:
<TableLayout
android:id="@+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableLayout>
Here is the result:
Thank you in advance for your attention.