Android Example Get all views or values of a CustomListView item

Discussion in 'Tutorials & Examples' started by LucaMs, Jul 21, 2017.

  1. LucaMs

    LucaMs Expert Licensed User

    I developed a simple example about how I think you should handle easily views and values of a CustomListView item.

    3 things:

    1) constants pointing to the views order in the item;
    2) two custom types, one for the views and the other for the values;
    3) four functions (you can find them in a Region named "GET CLV ITEM STUFF"):
    [EDIT] Now they are two functions only, version 2.

    Code:
    ' Returns views of item at the given item index.
    Sub GetItemViewsByIndex(ItemIndex As Int) As tItemViews 'ignore
    Code:
    ' Returns views of item that contains the given View.
    ' USES: function GetItemViewsByIndex
    Sub GetItemViewsByView(Vw As ViewAs tItemViews 'ignore
    Code:
    ' Returns values of item at the given item index.
    ' USES: function GetItemViewsByIndex
    Sub GetItemValuesByIndex(ItemIndex As Int) As tItemValues 'ignore
    Code:
    ' Returns values of item that contains the given view.
    ' USES: function GetItemValuesByIndex
    Sub GetItemValuesByView(Vw As ViewAs tItemValues 'ignore

    The test is not so smart, but it's about 4:00 AM, don't expect too much :D:

    1) check / uncheck the Sold checkbox.
    The item values will be get by view (the checkbox) and shown (ToastMessageShow and log);

    2) set focus on some Description EditText.
    Here the views will be get two times:
    first time by view (you will see change the beer and the Code text);
    second time, after 1.5 sec., by index (cancel previous changes)


    I hope you like it.

    Maybe I'll look for a way to make this more generic.


    Tips to improve this thing will be very welcome.


    [NOTE: I added GetDividerHeight to the CustomListView]


    Attached Version 2: see my posts #2 and #3.
     

    Attached Files:

    Last edited: Jul 21, 2017
    lucad likes this.
  2. LucaMs

    LucaMs Expert Licensed User

    My own tip :confused:

    I could need two only functions; the parameter could be of type object and I could check it:
    Code:
    ' Returns item's views
    Sub GetItemViews(IndexOrView As Object) As tItemViews 'ignore
      If IndexOrView Is View Then
         
    ' ...
       Else If IndexOrView Is Int Then
         
    '...
       Else
         
    ' invalid parameter
       End If

    Also, the item index could be wrong, so I have to handle this situation.

    Not now ! ;)
     
    LordZenzo likes this.
  3. LucaMs

    LucaMs Expert Licensed User

    This line:
    produces an error:
    An error occurred:
    (Line: 179) If IndexOrView Is View Then
    java.lang.ClassNotFoundException: java.lang.android.view.View


    so I solved using a bit different way.

    Attached Handle CustomListView V. 2 to the first post. It uses only two functions and checks if an item for the given item index exists.
     
    Last edited: Jul 21, 2017
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice