[英]change the spinner title bar style
我如何更改微调框标题栏样式。
我希望更改以下项目的标题栏:
icon
title textsize,textColor and
background color
我怎样才能做到这一点?
请帮助我...我已经搜索了谷歌和更多的网站。我没有得到任何解决方案。因此,请让我知道它的可能。如果可能的话,我该如何发展呢?
编辑:
这是我的代码:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row, R.id.country, list);
spinner.setPrompt("Choose a Status");
// spinner.setTextColor("#FF0000");
spinner.setAdapter(adapter);
adapter.notifyDataSetChanged();
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
您必须创建CustomSpinner,
为此,请尝试以下方式,对我来说效果很好
步骤1:创建自定义微调器类
class CustomSpinnerAdapter extends CursorAdapter {
LayoutInflater mInflater;
private int cocktailname;
CustomSpinnerAdapter(Context context, Cursor cursor)
{
super(context, cursor);
mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
cocktailname = cursor.getColumnIndex(YourDatabase.CK_NAME);
}
@Override
public View newDropDownView (Context context, Cursor cursor, ViewGroup parent)
{
return mInflater.inflate(R.layout.dropdownspinnertext, parent, false);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent)
{
return mInflater.inflate(R.layout.spinnertext, parent, false);
}
@Override
public void bindView(View row, Context context, Cursor cursor)
{
//Setting the Value here
TextView paymentname = (TextView) row.findViewById(R.id.text1);
paymentname.setTypeface(textFont);
String cocktail = cursor.getString(cocktailname);
paymentname.setText(cocktail);
}
}
第2步:调用此适配器
CustomSpinnerAdapter custom_spinneradapter = new CustomSpinnerAdapter(this,youcursor);
spnListCocktails.setAdapter(custom_spinneradapter);
spnListCocktails.setOnItemSelectedListener(this);
Xml for dropdownspinnertext
我正在使用Checked Dropdown Spinner
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:background="@drawable/background_image"
/>
对于spinnertext.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:gravity="center"
android:padding="4dip"
android:layout_marginLeft="10dip"
android:textSize="20sp"/>
希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.