I am writing an application in Android Studio. I want to implement two different students in the same class.
Here is a part of my code:
MyFragment extends Fragment implements AdapterView.OnItemSelectedListener, View.OnClickListener { //my fields private Spinner mySpinner; @Ovveride public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { //мой код } @Ovveride public void onNothingSelected(AdapterView<?>p){} @Ovveride public void onClick(View v) { //мой код } @Ovveride public void onCreate(Bundle b) { super.onCreate(b); //мой код mySpinner = (Spinner) fragmentView.findViewById(R.id.my_spinner); mySpinner.setOnItemSelectedListener(this); On the last line, I received an error:
'setOnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)' in 'android.widget.AdapterView' cannot be applied to '(anonymous android.view.View.OnClickListener)'
How to fix this error?
On the enSO write that you can do that.