androidでスピナーにアダプターをセットしたがスピナーの上枠線が表示されないのですが解決策はありますか。
あくまで推測ですが、スピナーの上にアダプターのテキストが重なっているのかもしれないですが、アダプターのサイズを変更しても上枠線は表示はされませんでした。
ソースは以下にあります。
どなたかご教授をお願いします。
activity.java
public class RowData { private String tes1; private String tes2; // コンストラクタ・セッタ・ゲッタ省略 RowData(String tes1, String tes2) { this.tes1 = tes1; this.tes2 = tes2; } public String gettes1() { return tes1; } public String gettes2() { return tes2; } @Override public String toString() { return tes2; } } : : : db = helper.getReadableDatabase(); // 列名の定義 String[] columns = {"tes1", "tes2", "tes3"}; // 得意先データの取得 Cursor cursor = db.query(DB_TABLE, columns, null, null, null, null, "tes1"); RowData[] dataArray = new RowData[cursor.getCount()]; // 取得したデータをテーブル明細部に設定 for (int i = 0; cursor.moveToNext(); i++) { dataArray[i] = new RowData(cursor.getString(0), cursor.getString(1)); } ArrayAdapter<RowData> adapter = new ArrayAdapter<>(this, R.layout.tk_list, dataArray); Spinner spinner = (Spinner) findViewById(R.id.n_naiyo); spinner3.setAdapter(adapter);
activity.xml(一部抜粋)
<Spinner android:id="@+id/n_naiyo2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginTop="-5dp" android:background="@drawable/spinner_border_sy" android:drawSelectorOnTop="true" android:text="Spinner"/>
drawable/spinner_border_sy.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#00000000" /> <stroke android:width="2px" android:color="#000000" /> <padding android:left="2px" android:top="2px" android:right="2px" android:bottom="2px" /> <corners android:radius="4px" /> </shape>
tk_list.xml
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textColor="#000000" android:textSize="25sp" android:background="@drawable/spinner_border_sy" />
あなたの回答
tips
プレビュー