我不需要任何花哨的东西,只需要列表中较大的项目(它太小)和不同的背景。目前它看起来像这样:
宣言如下:<Spinner android:id="@+id/sp_serverName" android:layout_width="fill_parent" android:layout_height="wrap_content" />
我使用代码绑定项目:
String[] items = new String[] { "Chai Latte", "Green Tea", "Black Tea" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
spinnerServerName.setAdapter(adapter);
spinnerServerName.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
Log.v("item", (String) parent.getItemAtPosition(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
// TODO Auto-generated method stub
}
});
答案 0 :(得分:0)
代替Android默认布局给你的是:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
替换为:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.custom_spinner_item, items);