Android Question listview save upload to file

zed

Active Member
Licensed User
Hi
If I understand correctly, you want to put data in a listview.
Listview is not a good solution. Use xCustomListView


A little more detail would help for better help.
 
Upvote 1
just understand that it is not possible to add a custom listview to AH Page Container gives an error I do not know why
B4X:
container.AddPage(CustomListView1.AsView,"Все")


*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
#SupportedOrientations attribute must be set to landscape or portrait.
*** mainpage: B4XPage_Created
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
b4xmainpage_b4xpage_created (java line: 302)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:302)
at b4a.example.b4xmainpage.callSub(b4xmainpage.java:922)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1068)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1039)
at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:548)
at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:885)
at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:219)
at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:226)
at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:736)
at b4a.example.main._activity_create(main.java:422)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8057)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
 
Upvote 0

zed

Active Member
Licensed User
There are parameters that have not been defined. It can't work
Can you post a project to clearly see what is wrong
 
Upvote 0
There are parameters that have not been defined. It can't work
Can you post a project to clearly see what is wrong
here is an example. A small part of the project cannot be added. If it doesn't work out, I'll throw the project to you
B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Dim lviz As ListView
    Private xui As XUI

    Dim TYPE_HELLO_WORLD As Int : TYPE_HELLO_WORLD = 1
    Dim TYPE_SETTINGS As Int : TYPE_SETTINGS = 2
    Dim TYPE_LISTVIEW As Int : TYPE_LISTVIEW = 3
    
    Dim FILL_PARENT As Int : FILL_PARENT = -1
    Private ime As IME
    Dim WRAP_CONTENT As Int : WRAP_CONTENT = -2
    Public Page2 As moddaho
    Dim container As AHPageContainer
    Dim pager As AHViewPager
    'Optionally you can use an AHViewPagerTabs object as a page indicator
    Dim tabs As AHViewPagerTabs
    
    'This panel is just for a colored line between the tabs and the pages.
    Dim line As Panel
    

    
    
    Dim la As CustomListView
    Private CustomListView1 As CustomListView

End Sub
Public Sub Initialize
    B4XPages.GetManager.LogEvents = True
    B4XPages.GetManager.TransitionAnimationDuration=0
    

End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.SetVisibleAnimated(0,True)
    
    'Add a Button at the bottom of the page for jumping directly to a page.
    Root.LoadLayout("1")
        container.Initialize
    For i = 0 To 1
        Dim pan As Panel
        
        Select i
            Case 0
                pan = CreatePanel(TYPE_HELLO_WORLD, "Избранное")
                container.AddPage(pan,"Избранное " )
            Case 1
                pan = CreatePanel(TYPE_SETTINGS, "Все")
            container.AddPage(pan,"Все")
        
        End Select
    Next
    index = SearchView1.SetItems(cities)
    index = SearchView1.SetItems(cities)
    
    'Now we have a container with our panels just add it to the pager object
    pager.Initialize2( container,"Pager")
    pager.PagingEnabled=True
    'As we want to show the tabs page indicator, we initialize it
    tabs.Initialize(pager)
    tabs.LineHeight = 10dip
    tabs.UpperCaseTitle = True
    Root.AddView(tabs, 0, 54dip, FILL_PARENT, WRAP_CONTENT)
    
    'We add a line below the tab page indicator because it looks good
    Dim col As ColorDrawable
    col.Initialize(tabs.LineColorCenter, 0)
    line.Initialize("")
    line.Background=col
    Root.AddView(line, 0, 54dip+35dip, Root.Width, 1dip)
    'Now we can add the pager to the activity
    Root.AddView(pager, 0, 54dip+35dip + 2dip, Root.Width, Root.Height-48dip-35dip-2dip)
    End Sub
    
    Sub CreatePanel(PanelType As Int, Title As String) As Panel
    Dim pan As Panel
    Dim pan2 As Panel
    Dim aq As Map

    pan2.Initialize("")
    pan2.LoadLayout("MainPage")
    Dim pi As PanelInfo
    Dim list1 As List
    pi.Initialize

    pi.LayoutLoaded = False
    pi.PanelType = PanelType
    pan.Initialize("")
    Select PanelType
        Case TYPE_HELLO_WORLD
            lviz.Initialize("lviz1")
            pan.AddView(lviz, 0, 0, FILL_PARENT, FILL_PARENT)
        Case TYPE_SETTINGS
            CustomListView1.Initialize("","")
            pan.AddView(CustomListView1.AsView, 0, 0, 100%x, 100%y)
    
    
    End Select
    
    pan.Tag = pi
    Return pan
End Sub
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
A way to do this is to add the customlistview to a layout. Load the layout into a panel and then add the panel to the PageContainer.
CustomListViews were not designed to be added outside a layout.

B4X:
        Case TYPE_SETTINGS
            CustomListView1.Initialize("","")
            pan.AddView(CustomListView1.AsView, 0, 0, 100%x, 100%y)
    
    
    Should be:
    
    Case TYPE_SETTINGS
        private p as b4xview = xui.createpanel("p")
        p.setLayoutAnimated(0,0,0,100%x,100%y)
        p.loadlayout("LayoutwithCLVonly") ' Make sure you set the anchors to cover the complete page
        pan.addview(p,0,0,100%x,100%y)
 
Reactions: zed
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…