スピナーに問題があります。日付によっては、 aまたは aでTableRow
aに追加する必要があります。Spinner で表示する必要がある私の配列は少し長いです。短いテキストを含む配列でコードをテストしたところ、次のようになりました。TextView
EditText
Spinner
ここでの唯一の問題は、スピナーが ではないことfill_parent
です。
配列をスピナーに配置すると、次のようになります。
この場合、スピナーはスピナーのようには見えず、EditText は表示されなくなります。スピナーを選択すると、次のビューが表示されます。
ここでは、配列のすべてのテキストを表示する必要があります。これは私のコードです:
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));
および 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"/>
誰でも私がそれを解決するのを助けることができますか? どんなアイデアでも大歓迎です。前もって感謝します。