1

I have created a custom layout which extends a RelativeLayout. It contains an ImageButton, a TextView and a RadioButton. Also I have a spinner and an ArrayAdapter for it. When I initialize the ArrayAdapter and set this custom layout as a layout resource and the TextView of this layout as a textViewResourceId, the layout is shown not only in dropdown view, but also in the spinner itself. Is it possible to display only the TextView in the spinner?

Victoria
  • 85
  • 1
  • 5
  • Don't have the ability to try right in front of me, but in the item selected listener, maybe set the spinner's background resource to the id of the selected text view? (keep in mind if the TextView is created in code, you need to set a unique id for it) – Drake Clarris Dec 12 '12 at 20:41
  • It doesn't help... Eclipse complains that "Resource is not a Drawable". – Victoria Dec 12 '12 at 21:01
  • Okay was a shot in the dark without code in front of me. Was worth a shot I guess – Drake Clarris Dec 12 '12 at 21:06
  • 1
    To hide something from view simply call YourTextView.setVisibility(View.GONE); or your YourLinearLayout... or YourSpinner... etc. – logray Dec 12 '12 at 21:11
  • Thank you, @logray. I have set onItemSelectedListener and it changes visibility of RadioButton and ImageView when an item is selected. – Victoria Dec 13 '12 at 07:27
  • 1
    Also I found another answer here: http://stackoverflow.com/a/4647702/1618760 , but haven't tried it yet. – Victoria Dec 13 '12 at 07:29
  • I don't mind, @Luksprog, but don't realize how it can help here. The problem is not the dropdown view, the problem is the view which is shown in spinner itself. Actually, I have solved the problem using the method which is described in the link above (in my previous comment). – Victoria Dec 13 '12 at 11:25
  • @Victoria glad you found solution, good job. – logray Dec 13 '12 at 15:35

0 Answers0