Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 更改微调器标题栏样式_Java_Android_Title_Android Spinner_Custom Titlebar - Fatal编程技术网

Java 更改微调器标题栏样式

Java 更改微调器标题栏样式,java,android,title,android-spinner,custom-titlebar,Java,Android,Title,Android Spinner,Custom Titlebar,如何更改微调器标题栏样式 我希望更改以下项目的标题栏: icon title textsize,textColor and background color 我该怎么做 请帮助我…我已经搜索了谷歌和更多的网站。我没有得到任何解决方案。所以请让我知道这是可能的。如果可能的话,意味着我如何开发这个???请解释我 编辑: 这是我的代码: ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,

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

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

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

 }
ArrayAdapter=新的ArrayAdapter(此,
R.layout.row、R.id.country、list);
setPrompt(“选择状态”);
//spinner.setTextColor(“FF0000”);
旋转器。设置适配器(适配器);
adapter.notifyDataSetChanged();
spinner.setOnItemSelectedListener(新的MyOnItemSelectedListener());
}
使用Java(代码):

spinner.setPrompt(“标题”)

来自XML:

android:prompt=“@string/spinner\u title

使用Java(代码):

spinner.setPrompt(“标题”)

来自XML:

android:prompt=“@string/spinner\u title


您必须创建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);
用于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"/>


希望对您有所帮助

您必须创建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);
用于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"/>


希望对您有所帮助

您能在这里添加源代码以便我们提供帮助吗u@SVarun请阅读我更新的问题并给出em解决方案。尝试Suraj Bajaj回答它可能对您有效您可以在此处添加源代码以便我们提供帮助吗u@S瓦伦请阅读我更新的问题,并给出em解决方案。请尝试Suraj Bajaj回答可能的问题为youtitle工作可以。如何更改标题文本颜色、标题文本大小和标题背景颜色是。我看到你的代码更新了。你已经在这样做了。让我再看一次。试试看:我不确定。标题是否可以。如何更改标题文本颜色、标题文本大小和标题背景颜色是的。我看到你的代码更新了。你已经在这样做了。让我再看一次。试试看:不过我不确定。