下拉菜单Spinner的效果如下图
布局文件
private String[] align= {"上对齐","下对齐","左对齐","右对齐"};
private Spinner sp;
private ArrayAdapter adapter;
private void setupView(){
sp =(Spinner) findViewById(R.id.sp);
adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, align);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//定义下拉菜单里的样式
sp.setAdapter(adapter);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupView();
}