java - 更改微调器标题栏样式

标签 java android title android-spinner custom-titlebar

如何更改微调器标题栏样式。

enter image description here

我希望更改以下项目的标题栏:

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 步:创建自定义 Spinner 类

    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);

dropdownspinnertext 的 Xml

我正在使用选中的下拉微调器

<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"/>

希望对你有帮助

关于java - 更改微调器标题栏样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12951203/

相关文章:

java - XML 目录文件无法解析

javascript - 部署后的 Ionic 应用程序给出 ReferenceError : Promise is not defined

android - Realm 迁移问题

javascript - 打开/关闭鼠标悬停时显示的标题

jquery - 我想从图像中获取标题属性并将其添加到周围的链接

ios - 数组索引超出范围

java - 优化 Eclipse

java - 如何获取链表中的Node组件?

java - 使用三种预先给定的方法反向打印字符串?

android - react 原生 : Crop image on Android