Android–下拉列表框(Spinner)

下拉列表框(Spinner)

package com.jiangge.spiderdeom;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class MainActivity extends Activity {
	Spinner spinner;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		spinner = (Spinner) findViewById(R.id.spinner_show);
		ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		adapter.add("Android");
		adapter.add("Ios");
		adapter.add("WindowPhone");
		spinner.setAdapter(adapter);
		
	}

}


    
		

發佈留言