これがあなたが探しているものです。また、使用方法によっては、スレッド化作業が必要になる場合もあります。
public class WineSearch extends Activity {
private static String[] names;
private static float[] ratings;
private static int[] ids;
ListView lv;
Context ctx;
TextView searchHeader;
ProgressDialog prgDiag;
Spinner spn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ctx = this;
searchHeader = (TextView) findViewById(R.id.SearchHeader);
lv = (ListView) findViewById(R.id.WineListView);
spn = (Spinner) findViewById(R.id.ListSpin);
ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.list_choice, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spn.setAdapter(adapter);
spn.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long arg3) {
Toast.makeText(parent.getContext(), parent.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
prgDiag = new ProgressDialog(this);
prgDiag.setCancelable(false);
this.refreshList();
}