Layout Not Appearing in CustomListView

Guardian17

Active Member
Licensed User
Longtime User
I was trying to use TableView for a word game app, but have since found that CustomListView would be better due to what I want to do with the views in the List.

I am loading a layout into each of the panels in CustomListView, but I am having problems making the panels and subviews visible.

I was going to attach the project as a ZIP file, but it is 440KB in size, slightly too large for an upload. Can I remove any files of the project folders to make the ZIP file smaller, but still have the project usable by anyone offering help (e.g.: me leaving out CustomListView and have it re-added by anyone trying to help, or deleting any specific project files)?
 

Guardian17

Active Member
Licensed User
Longtime User
Unbelievable!!!!!

:sign0105:
WOW!! I had been working on figuring out what I had to do to get the layout to appear properly for hours on end over two separate computer sessions, and couldn't get it to work properly. Lo and behold, this morning, I went to see what images I could remove to be able to ZIP the project up and Post it....

For some reason, the layout that I was loading into the panels of the CustomListView WAS NOT in my "Files" right-hand panel of the IDE. (If this were true in my previous sessions, wouldn't I have gotten some kind of error or exception???):confused:

After adding that layout to the Files list, and Compiling and Running, I am asked to provide a Layout Name in a "Save Layout" dialog that pops up. If I press "Cancel" in that popup, the project continues compiling and running, and [miraculously], the program does run properly where I do see the loaded layouts I was missing.

What Layout Name is it looking for me to provide? I don't want to type the name of my own panel layout for fear that whatever it wants to SAVE will overwrite that panel layout. Actually, I do recall this happening a few days ago when all of my layout-loading problems started happening. (Prior to my problem happening, I was getting the project to work properly).

Is it looking for the name of the layout that is defined in the Designer, which is simply one panel that the CustomListView gets loaded into? But again, I don't want to "Save" anything that will overwrite stuff that exists. I'd try providing some other Name to "Save", but I don't know what to call it or how this new name will relate to anything that's part of my project.:sign0085:
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Copy your project into a backup folder just to be safe... Can you upload your project ?
currently working with a CLV so might be able to help

Cheers mj
 
Upvote 0

Guardian17

Active Member
Licensed User
Longtime User
Main Code Listing

As mentioned, the ZIP file is 440K, too big to upload for a ZIP file on this forum.

Here is the Main Code Listing if that helps:

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim Width, Height As Int   :Width=30   :Height=30
   Dim WordLength As Int      :WordLength = 3
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim clv1 As CustomListView
   Dim Panel2, GuessedWordPanel As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("TestCustListView")
   clv1.Initialize(Me, "clv1")
   Panel2.Color = 0x20FFFFFF '130114 Colors.Transparent
   Panel2.Visible = True '130114
   'Panel2.LoadLayout("guessedwordpanel") '130114
   Panel2.AddView(clv1.AsView, 0, 0, Panel2.Width, Panel2.Height)
   For i = 0 To 39
      clv1.Add(CreateListItem("Item #" & i, clv1.AsView.Width, 50dip), 50dip, "Item #" & i)
      WordLength = WordLength + 1
      If WordLength > 7 Then
         WordLength = 3
      End If
   Next

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CreateListItem(myText As String, myWidth As Int, myHeight As Int) As Panel
   Dim p As Panel
   Dim lbl As Label
   p.Initialize("")
   p.LoadLayout("guessedwordpanel")
   'GuessedWordPanel.Initialize("")
   p.Visible = True
   For i = 0 To 8
      lbl.Initialize("")
      lbl = GuessedWordPanel.GetView(i) 'was p.GetView(i) '130114
      If i < WordLength Then
         lbl.Left = (i*30)+((8-WordLength)*15)
         lbl.Top = 7
         lbl.Visible = True
      Else
         If i>6 Then
            lbl.Left = i*30+30
            lbl.Top = 7
            lbl.Visible = True
         Else
            lbl.Visible = False
         End If
      End If
   Next
   Return p
End Sub


As previously mentioned by Erel, I don't have any images at all in this project. All of the items that are to appear on screen are labels and panels. My "Files" folder only has two Layout files and the CustomListView.bas file, with all 3 files taking only 14KB of space. The bulkiest files are in the "Objects" folder ("classes.dex" taking 279KB, and "TestCLV1_DEBYG.apk" taking 137KB, both uncompressed).

The "TestCustListView" layout only contains one Panel, "Panel2".

The "guessedwordpanel" layout is my layout that I load into each panel of the CustomListView, and has 12 Label Views inside it. After the layout is loaded into the panel, the labels get re-formatted according to other parameters in the program (namely "WordLength").

All of the comments with "'130114" were lines I was playing with yesterday (the date being 130114), before this morning's magical revelation, but certainly after/while I was having the previous problems.

Again, the project DOES work now, it's just that I don't know what to do with the dialog that pops up asking me to save the layout when I Compile and Run it.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Guardian .. I think you are trying to Zip your working project folder, which is not necessary.
Open your project ... File ... Export as Zip . Your project will be ziped and Debug.apk and classes.dex will not be included, resulting in much smaller size.

Cheers mj
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Guardian .. Take a look at the zip, Im unsure if this is what your trying to achieve.
The CustomListView is loaded to Panel2 and 40 rows are created,Each row containing 12 Labels. The GuessedWordPanel didn't seem to do anything ?

The labels Left position still needs some work as I didnt go in to what your trying to achieve regarding spacing ect/WordSize. Hopefully it will help

Cheers mj
 

Attachments

  • GuessedWordTest.zip
    10.1 KB · Views: 218
Upvote 0

Guardian17

Active Member
Licensed User
Longtime User
Main Layout Not Being Saved With Project

Thanks for the info on Exporting As Zip -- Yes, I was Zipping the entire folder from Windows Explorer. I'll keep this in mind for the future.

As for the main problem I am having, it seems that the Main project's layout is not being saved with the project in the Designer. I can go into the Designer and select "File | Main" to load the layout into the Designer, and then when I Compile and Run, everything works fine. But if that layout gets "Saved", and then I exit B4A, if I re-start B4A, load that project, and go back into the Designer, the Main Layout is not already loaded -- I have to re-select "File|Main" again to avoid seeing the "Save Layout" dialog, which seems to have been the root of my problem from a few days ago (probably because I gave a layout name that was the name of some other layout that I was using, so the other layout was overwritten with the "current" empty layout :confused:). And after experimenting with this this morning, seems to always be the case -- I always have to re-specify the Main layout prior to Compile/Run when re-starting a project, otherwise it always puts up the "Save Layout" dialog before continuing.

Is it proper procedure that, upon starting a project, I must always go into the Designer and select/load the Main project's Layout? If I perform a "File|Save" for the project while the Designer has the proper Main Layout loaded, why doesn't this layout get saved as the Main Layout in the Designer so I don't have to reload the desired layout into Designer each time I access this project?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Guardian

Is it proper procedure that, upon starting a project, I must always go into the Designer and select/load the Main project's Layout?

When you load a project it could have 10 layouts.. You go into Designer and load the layout you want to design / work with .. then save it .
Don't quote me here .. but that is separate from saving your project / Code.

did you have a look at the zip I uploaded .. was that along the lines of what your trying to achieve ?

Cheers mj
 
Upvote 0

Guardian17

Active Member
Licensed User
Longtime User
MJ:

Thanks for taking the time to look at my issues.

I was more interested in my problem at hand with the layouts. Newbies (like me) will be typically working with a single layout or maybe two layouts, when they start experimenting with B4A. It would seem more natural to me that, when the project gets saved, the most recent layout in the Designer would be saved along with the project, so that when the project is started the next time, that layout is re-loaded and I can continue working with the last layout that I was working on. If this were the default operation, anyone might see that maybe the default layout that has loaded is not the one they want to work with and would then load the layout desired.

A second issue with this is that, if there is NO LAYOUT presently in the Designer (because the project was just opened), why is the User prompted to Save the Designer Layout that is evidently EMPTY, but by providing any Layout Name, including possibly the one that they were working with for hours during the last B4A session, wouldn't that EMPTY layout then overwrite the tediously-prepared layout that had existed before this Save operation? This, I believe, is what happened to me, causing me to spend many hours (again, being a Newbie) trying to figure out what went wrong and where.

Regarding the Zip file you uploaded -- I just got to work (east coast, USA) and saw your reply, but won't be able to get back to looking at things until I get back home tonite where I experiment with B4A as a hobby. So I'll take a look at what you did, and maybe "Export As Zip" my version so you can see what I was trying to do.

Cheers!
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Guardian .. Newbie here as well .. Few years Vb but still learning the ropes /B4A layouts as well. I can see your point if you only have one layout its loaded default when entering designer. Once I've made any changes to a layout I Save the layout and close designer to gain extra monitor real estate anyway as designing for 10"tab ... an get on with the coding.

Just thought I could help as Project contains CLV which I've modified to suit.

You say B4A /Coding for a hobby .. same here .. what makes us pursue a hobby that entails banging your head against a brick wall every hour ...!

Cheers mj
 
Last edited:
Upvote 0

Guardian17

Active Member
Licensed User
Longtime User
My Version Attached

Tried what you had Zipped, but it wouldn't run. Said something about Loading a Label. This is the first time I did have to make a 1280x800 AVD.

Anyway, I've attached the project Exported as Zip ... what a difference -- only 11K instead of 444K!!

This was a test to be sure that I could load the labels as letters of the guessed words of different word lengths. I have since determined that what I wanted to do with the labels may be too difficult to do -- there are 3 labels that are gray, yellow, and blue as the 9th, 10th, and 11th views (last 3 views) from the Panel that gets loaded. Depending on the players usage, I was hoping to copy the attributes of these 3 labels to other labels as each guess is entered. But the way that a label is set to a GetView, essentially giving you control over the View that is retrieved, doesn't seem to allow me to set one view equal to another view to "trade" attributes, so, say, a grayed label could be made to be the dark blue label.

Anyway, this shows what I was trying to achieve. You can kinda see what the panel of 12 labels looks like if you un-comment Line 24 and break on the "For i = 0 to 39" line. If you don't break execution there, the other 40 line kind of overwrite that one panel load.

Thanks again or taking the time to help.
 

Attachments

  • TestCLV1.zip
    10.7 KB · Views: 209
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Guardian . hopefully someone with more experience will pick this up and solve any issues you have , cause I'm a little lost what your trying to do .Maybe start a fresh thread if no luck.
The were numerous error messages .. check your log
Warning: Panel.LoadLayout called with zero sized panel.
Hope things work out for your project .

Cheers mj
 
Last edited:
Upvote 0
Top