Android Code Snippet SD: Spinner with CustomView

Discussion in 'Code Snippets' started by Star-Dust, May 11, 2017.

  1. Star-Dust

    Star-Dust Active Member Licensed User

    I've created a new class with CistomView to have the same features on the spinner object as ListView. A second line of text and the ability to add an image beside each item.

    Also there is the ability to put the screen in gray when you click on the spinner. And finally, the ability to represent each item with rounded edges. In the cases there is an image that will also be rounded.

    Hope it may be useful to you

    Proprietes
    SelectedItem As String
    SelectedID As String
    SelectedIndex As String
    GrayDisplay
    As Boolean ' If Make Screeen gray when click (Set/Get)
    BColor As Int ' BackgroundColor of Spinner's Label (Get/Set)
    TColor As Int ' TextColor of Spinner's Label (Get/Set)
    HintColor As Int ' TextColor of Spinner's Hint (Get/Set)
    RoundCorner As Boolean

    Method

    Initialize
    (vCallback As Object, vEventName As String)
    Add(Text As String, TextHelp As String,ID As String, BackgroundColor As Int, TextColor As Int, Gravities As Int,Image As Bitmap)
    ' Add Single element
    AddAll(L As List, TextHelp As String, BackgroundColor As Int, TextColor As Int, Gravities As Int)
    ' Add a List

    Size as int ' return number of elements
    Clear ' Clear all elements
    RemoveIndex(Position As Int) ' Remove element at Index
    RemoveID(ID As String) ' Remove element from ID
    GetItem(Position As Int) As String ' Get Value from position/index
    GetItemFromID(ID As String) As String ' Get Value from ID
    GetID(Position As Int) As String ' Get ID at position/index
    SetIndex(Position As Int) ' Set selected from position/index
    SetID(Id As String) ' Set selected from ID
    SetBackgroundDrawable(Draw As ColorDrawable) ' Set Background with colordrawable
    SetBackgroundImage(Bitmap As Bitmap) ' Set Background with image
    SetLabelTextSize(TextSizeLabel As Int) ' Set Text Size of label
    Close ' close a ListItem windows
    Open ' Apen a ListItem Windows

    Event
    ItemClick (Position As Int, Value as String)

    Screen1.png Screen2.png Screen3.png Screen4.png Screen5.png Screen6.png
     

    Attached Files:

    Last edited: May 18, 2017
  2. Star-Dust

    Star-Dust Active Member Licensed User

    Add a Little animation
     
  3. MarcoRome

    MarcoRome Expert Licensed User

    Good Job ;).
    Bravo
     
  4. PABLO2013

    PABLO2013 Active Member Licensed User

  5. Filippo

    Filippo Expert Licensed User

    Bravo! but "Non so"

    Bravo! perĂ² "Non so" :D
     
    Star-Dust likes this.
Loading...