这是我的Spinner,其中已安装的应用程序的包名称为ArrayList。它工作正常,但微调器项目上的文本显示为白色,文本不可见,直到聚焦。我需要将项目颜色设置为黑色,我该怎么办?
public class AppList extends Activity
{
private Spinner spinner;
private ArrayList results = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState);
setContentView(R.layout.main);
spinner = (Spinner)findViewById(R.id.Button);
PackageManager pm = AppList.this.getPackageManager();
Intent intent = new Intent( Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List list = pm.queryIntentActivities(intent,
PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list)
{ results.add(rInfo.activityInfo.packageName.toString());
}
spinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, results));
}}
答案 0 :(得分:2)
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, array);
adaptersetDropDownViewResource(R.layout.your_layout);
spinner.setAdapter(adapter);
使用textview制作布局xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textcolor="@android:color/black"/>
答案 1 :(得分:0)
扩展适配器,并自定义getView
和getDropdownView
中的视图。
答案 2 :(得分:0)
修改 simple_list_item_1 .xml文件
添加此文本视图;
android:textColor="#000000"
答案 3 :(得分:0)
ArrayAdapter<String> adap = new ArrayAdapter<String> (this,
android.R.layout.simple_
spinner_item, your_array );
adap.setDropDownViewResource(R.layout.row);
spinner.setAdapter(adap);
现在自定义row.xml中的文本