下拉菜单Spinner

下拉菜单Spinner的效果如下图

下拉菜单Spinner_第1张图片


布局文件

    
        
        
        
    

代码

	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();
	}


你可能感兴趣的:(Android_UI)