Tengo algunos problemas con la ruleta. Dependiendo de mis fechas, debo agregar a TableRow
a TextView
con EditText
o Spinner
. Mi matriz que debe mostrarse en Spinner es un poco larga. Probé mi código con una matriz con textos cortos, y se ve así:Spinner con texto largo no funciona bien
Aquí el único problema es que la ruleta no es fill_parent
.
Si pongo mi matriz a spinner se ve así:
En este caso, la ruleta no se ve como una ruleta y el EditarTexto no es visible más. Cuando elijo la ruleta, parece que este punto de vista:
Aquí tengo que mostrar todo el texto de la matriz. Este es mi código:
TableRow.LayoutParams lp = new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT , TableRow.LayoutParams.WRAP_CONTENT);
tablerow_product[i] = new TableRow(viewToLoad.getContext());
tablerow_product[i].setLayoutParams(lp);
product_spinner[i] = new Spinner(viewToLoad.getContext());
product_spinner[i].setLayoutParams(lp); product_spinner[i].setBackgroundResource(R.drawable.spinner_selector);
String[] proba={"red","blue"}; //first image is with this test array
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(viewToLoad.getContext(), com.Orange.R.layout.my_spinner_textview,spinnerArray); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
product_spinner[i].setAdapter(spinnerArrayAdapter);
tablerow_product[i].addView(product_spinner[i]); Themes_TableLayout.addView(tablerow_product[i],new TableLayout.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
y my_spinner_textview.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@drawable/textorange_selected"
android:gravity="left"
android:singleLine="false"
android:ellipsize="end"/>
Puede alguien ayudarme a solucionar esto? Cualquier idea es bienvenida. Gracias por adelantado.
vez revisa este enlace http: //android-coding.blogspot.i n/2011/12/dynamic-change-content-of-spinner.html – shassss
La respuesta a esta pregunta resolvió mi problema: http://stackoverflow.com/questions/2325242/android-how-do-i-add-1 -views-in-one-cell-for-tablerow – Gabrielle
@Bhargavi Pronto publicaré una respuesta con mi código. – Gabrielle