B4A Class SLSPinner - Android 4 style spinner for all API's

stevel05

Expert
Licensed User
Longtime User
No I hadn't thought about that, if the parent is a scroll view, it's position will have to be recalculated each time it's accessed.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Steve, for this and all of your contributions to the forum.

The SLSPinner contains some of the attributes which should be part of the V4 Standard Spinner. It is simply just a better spinner.

For those who do not have a device with an pre 4 Android version, you can simulate the "standard spinner" behavior by adding this line to the manifest:

B4X:
SetActivityAttribute(main, android:theme, "@android:style/Theme.Translucent")

I came to this discovery, not by brilliant wisdom, but merely by chance since I ran into the issue of a spinner reverting back to "pre Android 4" when I added this line to the Manifest Editor.

I created a new thread related to a question on the behavior of other views when Theme.Traslucent is used:

http://www.b4x.com/android/forum/threads/translucent-theme-affects-behavior-of-some-views.44932/

Best regards.

Sandy
 
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Pretty cool but gravity right is not working properly, items are almost not visible.
 

stevel05

Expert
Licensed User
Longtime User
Hi BlueDude,

The border was covering part of the listview item, try the attached.
 

Attachments

  • slspinner2.zip
    15.7 KB · Views: 235

bluedude

Well-Known Member
Licensed User
Longtime User
Good start but not completely, see attached screen for two issues. When gravity is right the selected value is too much to the right (on top of the selection triangle). Second, when the dropdown is generated gravity is center.

Where exactly can I fix this in the code? Maybe some padding on top of gravity would be flexible.

One other thing I was wondering is how to set the border the same as the background of the list.
 

Attachments

  • Screenshot_2014-10-24-09-36-55.png
    41.8 KB · Views: 303

stevel05

Expert
Licensed User
Longtime User
With this version I've added a ButtonPadding(Left,Top,Right,Bottom) Method, so you can set the padding as you want it. You will need to do a Bit.Or on the Gravity, Bit.Or(Gravity.Right,Gravity.Center_Vertical) or it will set gravity to Right Top by default.

You can change the border color using the ListBorderColor method.
 

Attachments

  • slspinner3.zip
    15.8 KB · Views: 222

bluedude

Well-Known Member
Licensed User
Longtime User
The padding is cool and a solution but my problem is the gravity in the dropdown, see attached picture. It also needs to put values at the right. Not sure why it displays some pixels from the left when the width becomes bigger.
 

Attachments

  • Screenshot_2014-10-24-15-51-17.png
    43.3 KB · Views: 285

stevel05

Expert
Licensed User
Longtime User
Hi bluedude, it's a while since I've looked at this I have to go out this evening, so I'll take a better look tomorrow.
 

stevel05

Expert
Licensed User
Longtime User
OK, try this one. The reason was that the label width in the list was not being adjusted, it should work now. I've also put 20Dip right padding in as default which you can still change if needed.
 

Attachments

  • slspinner4.zip
    15.8 KB · Views: 240

bluedude

Well-Known Member
Licensed User
Longtime User
Hi, that works great! One other question. I want to adapt the backcolor, border automatically to the Android OS it runs on. Just like the default spinner.

Any suggestions?
 

bluedude

Well-Known Member
Licensed User
Longtime User
Hi, also setting the listborder smaller will kill gravity settings in dropdown.

Backcolor adaption works BTW.
 

bluedude

Well-Known Member
Licensed User
Longtime User
One very tiny styling thing. Can the dropdown text be right gravity with some kind of offset? When there is a scollbar the scrollbar is over the text, would like do have the text slightly more to the left (padding or offset).

Would like to know how to change it myself.
 

stevel05

Expert
Licensed User
Longtime User
Hi Bluedude,

The attached fixes the first issue, changing the border width reset the width of the label, (see Sub setListBorderSize) I have changed this to use the current size.

The default padding is set in Sub SetUpButton, you can change the value (currently 20) as you like.

When you're happy with this, I'll upload it to the first post.

Thanks

Steve
 

Attachments

  • slspinner5.zip
    15.8 KB · Views: 259

bluedude

Well-Known Member
Licensed User
Longtime User
Hi, the issue I'm talking about is the problem in the dropdown where all the values show. Gravity right works but the values are really tight to the right edge, it does not look too good especially when there is a scroll feature.

The padding is not working in the list.
 

stevel05

Expert
Licensed User
Longtime User
OK, I'm with you. I thought it would be as simple as adding padding to the SPList.SingleLineLayout.Label, but that's causing a ClassCastException. I'm out for the rest of the day, I'll try and take a look tomorrow.
 

johndb

Active Member
Licensed User
Longtime User
OK, I'm with you. I thought it would be as simple as adding padding to the SPList.SingleLineLayout.Label, but that's causing a ClassCastException. I'm out for the rest of the day, I'll try and take a look tomorrow.

Is Spinner5.zip the latest or has the first post been updated with the latest revisions?
Has the issue related to placing the spinner on a scrollview been resolved?
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Hi John,

Spinner5 is the latest version, this issue was not completed. If it causes you any problems I'll add it to my current list and revisit it when I get a chance.

Steve
 

ArminKH

Well-Known Member
Hi stevel
Thank u 4 sharing this usefull class
What is the difference between normal version and pre version?
The difference is in android version or basic version?
I use normal version now,thats okay in all android version?
Tnx again
 

stevel05

Expert
Licensed User
Longtime User
There is no functional difference, just the code syntax is slightly different for the Pre 3.2 version.
 

ArminKH

Well-Known Member
Ok tnx
But which version we can use?the first post link is updated?because i have same issue with right edge padding with persian and arabic language(right to left)
Now we must download your lib from first post or download slspinner5 ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…