private Spinner spinner;
private String[] list = {"test1","test2","test3"};
private ArrayAdapter<String> listAdapter;
private Context mContext;
spinner=(Spinner)findViewById(R.id.spinner);
mContext = this.getApplicationContext();
listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item , list);
spinner.setAdapter(listAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long arg3) {
Toast.makeText(mContext, "你選的是"+list[position], Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
private String[] list = {"test1","test2","test3"};
private ArrayAdapter<String> listAdapter;
private Context mContext;
spinner=(Spinner)findViewById(R.id.spinner);
mContext = this.getApplicationContext();
listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item , list);
spinner.setAdapter(listAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long arg3) {
Toast.makeText(mContext, "你選的是"+list[position], Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
沒有留言:
張貼留言