新しいスピナーを動的に作成しています。リストの背景色を変更するにはどうすればよいですか?
現在の背景色は濃い灰色です。
スピナーの背景属性を白に変更すると、次の望ましくない状況が発生します。
アクティビティで透明にしたいのですが、スピナーを開いたとき (押したとき) だけ、背景を白くしたいです。
スピナーを作成しているコードは次のとおりです。
私はアダプタを作成しています:
mAdapter = new ArrayAdapter<String>(getApplicationContext(),
R.layout.spinner, R.id.Language, lang);
LinearLayout layoutHolder =
(LinearLayout)findViewById(R.id.RegisterFormLayout);
Spinner spinner = new Spinner(getApplicationContext());
LayoutParams layParams= new
Spinner.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
spinner.setLayoutParams(layParams);
spinner.setAdapter(mAdapter);
spinner.setOnItemSelectedListener(new myOnItemSelectedListener());
if (lang != null)
spinner.setSelection(lang.intValue());
spinnerList.add(spinner);
layoutHolder.addView(spinner);
私の spinner.xml レイアウトは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/SpinnerLayout">
<TextView
android:id="@+id/Language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="#00ffffff"
android:padding="5dp" />
</LinearLayout>
なにか提案を?