I select a table and it returns a complete row. I put that row into an object. My intention is to collect the value and inflate a spinner so that if it finds for example in the select: "8" I generate a spinner with values from 1 to 8. I have found several guides online but I am unable to do so. Any help?
XML:
<LinearLayout
android:id="@+id/manejadorLayout"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:layout_below="@+id/textLayout">
<TextView
android:id="@+id/textViewVnt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:text="Vender:" />
<Spinner
android:id="@+id/Sp"
android:layout_width="200dp"
android:layout_height="match_parent"></Spinner>
<Button
android:id="@+id/buttonInvertirTick"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="50dp"
android:background="@drawable/success" />
</LinearLayout>
Java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_amazon_venta);
sp = (Spinner) findViewById(R.id.Sp);
textView = (TextView) findViewById(R.id.textViewTextoV);
opera = new OperacionesBaseDatos();
carteraObj = opera.leerCartera(10);
if (carteraObj.getCantidad() > 0) {
textView.setText("Dispone de " + carteraObj.getCantidad() + " acciones de Amazon INC con un coste de " + carteraObj.getPrecio() + " de media. Actualmente se cotiza a la acción");
} else {
textView.setText("No dispone de ninguna accion en propieded de esta entidad");
}
}
The values to insert in the spinner would be obtained with portfolioObj.getQuantity () and would go inside the if (portfolioObj.getQuantity ()> 0)