<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
package com.cho.spinnerdemoa2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class SpinnerDemoA2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] numbers ={"1","2","3","4","5"};
Spinner spinner = (Spinner)findViewById(R.id.spinner1);
//ArrayAdapter 클래스는 배열의 데이터를 지정된
//android.R.layout.simple_spinner_item 레이아웃으로 표현해주는 역할.
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, numbers);
spinner.setAdapter(adapter);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setSelection(2);
}
[Android]Key / Touch event (0) | 2012.01.28 |
---|---|
[Android] Activity (0) | 2011.11.13 |
[Android] Edit Text (0) | 2011.08.09 |
[Android] Button (0) | 2011.08.03 |
[Android] 스타일 과 테마 (0) | 2011.07.31 |
댓글 영역