我的代码类似于以下内容:
package com.javasamples;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
public class ArrayAdapterDemo2 extends Activity implements
AdapterView.OnItemSelectedListener {
TextView selection;
String[] items = { "this", "is", "a", "really",
"really2", "really3",
"really4", "really5", "silly", "list" };
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
selection = (TextView) findViewById(R.id.selection);
Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter aa = new ArrayAdapter(
this,
android.R.layout.simple_spinner_item,
items);
aa.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
}
public void onItemSelected(AdapterView<?> parent, View v, int position,
long id) {
selection.setText(items[position]);
}
public void onNothingSelected(AdapterView<?> parent) {
selection.setText("");
}
}//class
在从微调器列表中选择后,我需要在哪个地方实现一些东西,例如,我的程序将更改背景图片。我一直在寻找类似 setOnClickListener 的东西,但实际上没有它它也能工作,在这种情况下,我不知道该怎么做。