Android Question Add a CustomView to a Panel Inside a ListView

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi,

does anybody knows how to add a CustomView to a Panel in a CustomListView (Ultimate List View)? When referencing the object in the call back fill event I'm getting an error for any kind of CustomView.
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
AFAIK CustomViews can only be added through the Visual Designer
check this https://www.b4x.com/android/forum/t...-enhanced-designer-support.62488/#post-400215
Hello,
I added the view using Visual Designer... Then, loaded the Layout to a panel in a Ultimate List View. But once inside a panel, I cant reference it anymore. The Ultimate List View generates an event to populate the panels when showed at screen and it's needed to GetViews from panel... this is the step that doesn't work: doesn't matter what I do, I can't reference a CustomView inside a panel added in a ULV. The error is:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tillekesoft.b4agifview.GifView.setGifPath(java.lang.String)' on a null object reference

I think that the problem is that we need to define a local object to reference the customview loaded... the problem is this reference... for example:

Dim GifPlayer2 as GifPlayer = layoutpanel.getview(4)

and later:
GifPlayser2.SetGif("gifpath") ... --> error!

The same error occurs with GifPlayer and other customviews...

any suggestion?
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi @msali ... my situation is a little bit different: in yours, you must to get a reference to a view inside a panel that generated an event. In mine, I need to put a customlview in a panel in other specific customview (UltimateListView) . This customview INSIDE other always raises a null error when I try to populate. In your situation, the target view is OUTSIDE the panel...

Anyway, really thanks for answering!
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
CustomListView is not the same as UltimateListView. Adding custom views to xCustomListView is simple. You don't need to do anything special for this.

Thanks @Erel ... Unfortunately, the app is now fully based on ULV. When I have some time I'll try do develop a version using xCustomView . Anyway, I think as you answered to me in this thread (https://www.b4x.com/android/forum/threads/gifviewer-panel-reference.93606/#post-592603) that you noticed also the problems involving to show high memory expending objects in panels. For gifs, for example, I'm trying to load a gif with 2Mb in panels and the device runs to "out of memory" with only two panels on the screen. The best solution could be to have a routine to compress gifs (and maybe videos), but there is no such library in B4A. I did some research and realized that there are some libraries in java to do this. Finishing this project, I'll do a wrapper of one of these libraries and post here.
For now, I think that the most secure solution is to show a thumbnail of the object in the list panel and open a new activity with the correct player when clicked.

Thanks for the patience and the time that you spent with my posts @Erel
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User

you can get gif frames as bitmaps then resize this bitmaps and keep them in the memory (only for onscreen visible items)
use imageview and timer to show the bitmaps animated in the list item
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
you can get gif frames as bitmaps then resize this bitmaps and keep them in the memory (only for onscreen visible items)
use imageview and timer to show the bitmaps animated in the list item
Hi @KZero ... it's a really good solution, besides I'm not sure if a timer will generate a good performance for a list with many gifs.. maybe the best solution is to wrap some gif library in java with compress features...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…