vendredi 10 février 2017

Android Studio Spinner doesn't react to click

Vote count: 0

I have a Spinner in my fragment but when I click the spinner I don't get the actual dropdown list to show

Here is the java for my Spinner

 private void createCommissionDropDownList(){
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, mReportViewModel.getCommissionNames());
    arrayAdapter.setDropDownViewResource(R.layout.spinner_my_spinner_item);
    Spinner spinner = (Spinner) mBaseLayout.findViewById(R.id.commissionSpinner);
    spinner.setVisibility(View.VISIBLE);
    spinner.setAdapter(arrayAdapter);

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            int itemId = (int) id;

               if(itemId == 0) {
                   Toast.makeText(getContext(), mReportViewModel.getCommissionNames().size() + "", Toast.LENGTH_LONG).show();
               }

        }
        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });
}

Here is my xml for the Spinner

     <Spinner
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:id="@+id/commissionSpinner"
        android:visibility="gone"
        android:background="@color/colorPrimary"/>

The image below shows how it looks like

P.S I do call the method that creates the spinner earlier the code

enter image description here

The yellow is the actual spinner, it respond to my clicks however

asked 20 secs ago

Let's block ads! (Why?)



Android Studio Spinner doesn't react to click

Aucun commentaire:

Enregistrer un commentaire