Write a stand along interface or not like this,
spinner.setAdapter(this.mAdapter);
OnItemSelectedListener spinnerListener = new OnItemSelectedListener(this,this.mAdapter);
spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(parent.getContext(),"The planet is "+ parent.getItemAtPosition(pos).toString(),Toast.LENGTH_LONG).show();
textViewa.setText("You choose :"+ " " + mAdapter.getItem(arg2));
arg0.setVisibility(View.VISIBLE);
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
textViewa.setText("NONE");
arg0.setVisibility(View.VISIBLE);
}
});
and this one,
public class SpinnerActivity extends Activity implements OnItemSelectedListener { ...
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { // An item was selected. You can retrieve the selected item using // parent.getItemAtPosition(pos) } public void onNothingSelected(AdapterView<?> parent) { // Another interface callback } }
what's different?