Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

android - How to change spinner text color

I saw many topics about how to change spinner's text color,but i couldnt understand how to use

spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:singleLine="true"
    android:textColor="@color/iphone_text" />

What shall i really do in java code:? Any responses will be aprecieted Please answer clearly with as more details as you can

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A complete answer for me would be something like:

public class ee extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ww);
        addListenerOnSpinnerItemSelection();

    }

    public void addListenerOnSpinnerItemSelection() {
        ArrayList<String> array = new ArrayList<String>();
        array.add("item0");
        Spinner spinner1;
        ArrayAdapter<String> mAdapter;
        spinner1 = (Spinner) findViewById(R.id.spinner2);
        mAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, array);
        spinner1.setAdapter(mAdapter);
    }

}

and in res/layout add new xml file:

(in spinner_item.xml)

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:singleLine="true"
    android:textColor="#00f0ff" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...