1.在XHL中:
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@+array/other" />
在string.xml中
<String-Array name="desk"
<item>小说</item>
<item>散文</>
<item>诗词</>
</Stirng-Array>
2.首先定义一个xml文件
<Spinner
android:id="@+id/desk"
android:layout_width="wrap_content"
android:layout_height="match_parent"
</Spinner>
其次在activity类中如此定义:
private Spinner spinner;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setcontentview(R.layout.desk);
spinner=(Spinner)findViewById(R.id.desktop);
String str[]={"好人","坏人"};
ArrayAdapter man=new ArrayAdapter(this,android.R.layout.simple_spinner_item,str};
spinner.setAdapter(man);