如何更改微调器标题栏样式。
我希望更改以下项目的标题栏:
icon
title textsize,textColor and
background color
我该怎么做?
请帮助我...我已经搜索了谷歌和更多sites.am没有得到任何解决方案。所以请让我知道它的可能。如果可能的话,我怎么能发展这个????请解释我。< / p>
修改
这是我的代码:
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());
}
答案 0 :(得分:2)
使用Java(代码):
spinner.setPrompt("Title")
OR
来自XML:
android:prompt="@string/spinner_title
答案 1 :(得分:2)
您必须创建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"/>
希望有所帮助