- 스피너에 노출되는 텍스트 색상지정 , 텍스트 정렬방법입니다.
-------------------------------------------------------------------------------------------------
private void setSpinner() {
setContentView(R.layout.spinner);
Spinner select_distance = (Spinner) findViewById(R.id.select_item);
spinnerdapter = ArrayAdapter.createFromResource(AroundMeActivity.this, R.array.distance_array,R.layout.spinner_item);
spinnerdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
select_distance.setAdapter(spinnerdapter);
select_distance.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,View view, int pos, long id) {
String spinnerName = parent.getItemAtPosition(pos).toString();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
-------------------------------------------------------------------------------------------------
spinner.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="@+id/select_item"
android:layout_width="50dip"
android:layout_height="100dip"
android:prompt="@string/distance"
android:background="@drawable/spinner_background" >
</Spinner>
</LinearLayout >
-------------------------------------------------------------------------------------------------
spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_spitem"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="14dip"
android:textColor="#ff00ff"
android:gravity="center"/>
-------------------------------------------------------------------------------------------------
value/strings.xml
<string-array name="distance_array">
<item>1Km</item>
<item>3Km</item>
<item>5Km</item>
</string-array>
-------------------------------------------------------------------------------------------------
'안드로이드' 카테고리의 다른 글
AlertDialog.Builder 안에 텍스트 사이즈 조절하기 (0) | 2013.04.26 |
---|---|
R.array 를 스트링 배열로 변환 (0) | 2013.04.18 |
WebView 높이 wrap_content 주는 방법 (0) | 2013.04.09 |
SharedPreferences 사용법 (0) | 2013.04.05 |
android google map v2 지도 터치시 마커 찍기 (0) | 2013.01.23 |