1、创建XML文件
<?xml version="1.0" encoding="utf-8"?>
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/idspinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Spinner android:id="@+id/idspinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">>
</Spinner>
</Spinner>
2、新创建一个Activtiy文件
package com.example.jj;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner
/**
* Created by Administrator on 14-11-25.
*/
public class Actitiy_spinner extends Activity {
//定义属性
private Spinner mspinner;
private String[] array=new String[]{"后悔","传达出","对错"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.spinner_xml);
//初始化属性
mspinner=(Spinner)findViewById(R.id.idspinner);
//绑定Adapter
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,array);
mspinner.setAdapter(adapter);
}
}
-END