Android Question Costomized Expandable List

trepdas

Active Member
Licensed User
Hello there Erel and rest of you good people.


I want to create an expandable list as shown in the example here :


I've built the text file in vb6 , author's name starts with '###' followed by list of books. (Pretty big file, 2.5 mb)

my data txt file looks like this :

data.txt:
<!start>
###William Shakespeare
Hamlet
Othello
King Lear
Macbeth
###Ernest Hemingway
The Sun Also Rises
A Clean Well Lighted Place
The Torrents of Spring
An Alpine Idyll
###Agatha Christie
The Murder on the Links
The Big Four
Black Coffee
Cards on the Table
<!end>

where the author's name in the main title and the list of books will show in the expandable list.
(each book has to be clickable for action,of course)

a good starting example of code from those of you who can make it in a minute
will be very and greatly appreciated
 
Last edited:

trepdas

Active Member
Licensed User
Hello there Erel and rest of you good people.



I want to create an expandable list as shown in the example here :


I've built the text file in vb6 , author's name starts with '###' followed by list of books.

my data txt file looks like this :

data.txt:
<!start>
###William Shakespeare
Hamlet
Othello
King Lear
Macbeth
###Ernest Hemingway
The Sun Also Rises
A Clean Well Lighted Place
The Torrents of Spring
An Alpine Idyll
###Agatha Christie
The Murder on the Links
The Big Four
Black Coffee
Cards on the Table
<!end>

where the author's name in the main title and the list of books will show in the expandable list.
(each book has to be clickable for action,of course)

a good starting example of code from those of you who can make it in a minute
will be very and greatly appreciated

🙏 🙏 🙏
 
Last edited:
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
There is no need to bump ... we'll get there eventually.

I could not get my head around looping through your text file ... so it has been processed to a database first (progmatically - see Starter Service)
I believe this is the simplest method to populate the CLV List... and as your list grows would it not be good to add new titles inApp.

Why VB6 ? B4J is a pleasure / easy to use and there are many SQL tutorials examples to migrate from VB6

Anyway ... the example is commented , so hopefully you can gain something from it.



Edit / ps: If you still want to iterate thru your text file , you could you TextReader and adapt the Starter.ProcessDataToDB code to suit
 

Attachments

  • clvExpand Books Example.zip
    13.4 KB · Views: 146
Upvote 0

trepdas

Active Member
Licensed User
Why VB6 ? B4J is a pleasure / easy to use and there are many SQL tutorials examples to migrate from VB6

That is because I am a dinozaur who started off 40 yrs ago with VIC20 followed by Commodore64 and had some time to adjust the new tech.
:)
for many years I got stuck with vb6 and still refuse to let go...


thx again for the code ! it helped me understand some obvious things .///finally...


since my future projects will be focusing mainly with SQL , I'll consider moving on to B4J...
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
we'll get there eventually.
That is a nice example mj in post 3. Once you click on an author, you see the list of books by that author. I would like to display the book name when I click on a given book. I tried this, but it only displays the author:
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
    expandable.ToggleItem(Index)
    Dim e As ExpandableItemData
    e.Initialize
    e=Value
    Log(e.Value) 'displays the author, but I like to click a book from the list to display the book
End Sub
Thank you
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I would like to display the book name when I click on a given book.


Probably the simplest method , assign Event Name when adding/initializing the Label in CreateItem() sub ... then
B4X:
Sub BookTitle_Click
    Dim lbl As B4XView = Sender
    Log(lbl.Text)
End Sub


as a side note ... I have had this Click_Event example code working previously ... but for some reason cannot access the book title Labels ...

Still Investigating ... (maybe due to Labels being dynamically added to panel ??)
 
Last edited:
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I have made some changes to the example posted above (see post #3)

The dynamically added views (Labels) should have been loaded to pnlExpanded.
This then allows you to access the views in the clv1Click_Event. I have also added a Click event for the individual book titles.

Also there is some code to automatically collapse previous expanded panel. (with a link to original code)

Cheers
 

Attachments

  • clvExpand Books Example 2.zip
    13.7 KB · Views: 148
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The dynamically added views (Labels) should have been loaded to pnlExpanded.
When you click on any author it displays the author and all the books associated with tthat author. When you click on a book title, it displays the same exact thing as above: Author and all the book titles, not just the clicked title. In both cases the clv1 intercepts the click event.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
When you click on a book title, it displays the same exact thing as above: Author and all the book titles, not just the clicked title. In both cases the clv1 intercepts the click event.

Sorry.. here it does not.

Edit the BookTitle_Click event and see if you still think that the case ...
B4X:
Sub BookTitle_Click
    Dim lbl As Label = Sender
    Log("  ")
    LogColor("Clicking the Book Title Only... " & lbl.Text, Colors.Blue)
End Sub



Edit: attached edited example suppressing a few logs ... nothing more
 

Attachments

  • clvExpand Books Example 2.zip
    13.7 KB · Views: 164
Upvote 0
Top