无法获得微调器的选定值。
public class Create extends Activity {
public ArrayList<String> spinnerlist;
Button button4;
String spinnertext;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create);
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
spinnerlist=new ArrayList<String>();
spinnerlist.add("ATM");
spinnerlist.add("Bank");
spinnerlist.add("Mail");
spinnerlist.add("Others");
spinnerlist.add("Personal");
spinnerlist.add("Social Network");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, spinnerlist);
adapter.setNotifyOnChange(true);
spinner.setAdapter(adapter);
spinner.setLongClickable(true);
spinner.setOnLongClickListener(new OnLongClickListener(){
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
spinnertext = spinnerlist.**getSelectedItem()**.toString();
return false;
出现错误:方法getSelectedItem()未为 ArrayList 类型定义
}
});
button4 = (Button)findViewById(R.id.button4);
button4.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent5 = new Intent(view.getContext(), Details.class);
startActivityForResult(myIntent5, 0);
myIntent5 .putExtra("key", spinnerlist.getSelectedItem().toString());
startActivity(myIntent5);
}
});
}}
我无法将字符串值转移到下一个活动?