Setting ID for Spinner items

后端 未结 5 2054
温柔的废话
温柔的废话 2020-12-25 12:50

I have an array of Strings I\'m populating a Spinner object with. However, I\'d like to attach an ID to each element of the Spinner, so when the user selects an item, I hav

5条回答
  •  借酒劲吻你
    2020-12-25 13:11

    Andrew Hi, it's been a long time but it's worth to write.

    You can set a tag for each row when you'r inflating spinnerLayout in SpinnerAdapter:

    spinnerView = inflater.inflate(spinnerLayout, parent, false);
    spinnerView.setTag("Your Tag");
    

    And then you can get the tag with:

    yourSpinner.getSelectedView().getTag();
    

提交回复
热议问题