Android Question read/write list view

Discussion in 'Android Questions' started by mohsen nasrabady, Jan 29, 2015.

  1. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    hi i used this code to read a listview but error
    java.lang.RuntimeException: Object should first be initialized (ListView).

    but the listview is initialized

    what's the problem?

    Code:
    Dim ra As RandomAccessFile
    ra.Initialize(
    File.DirInternal,"gamelist",False)
    gamelist = ra.ReadObject(
    0)
    gamelist.Invalidate
    ra.Close
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    ok thnx but there is no way to save a listview?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You cannot save views to a file. You can save the data to a file.
     
  5. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    i used this code to save the listview with two line and bitmap
    the recoglist and recogsize is map
    i did the data of two line and bitmap in the maps
    Code:
    For i = 0 To list1.Size-1
    gamelist.AddTwoLinesAndBitmap(list1.Get(i),recogsize.Get(list1.Get(i))&
    " MB",recoglist.Get(list1.Get(i)))
    Next
    Dim ra As RandomAccessFile
    ra.Initialize(
    File.DirInternal,"gamelist",False)
    ra.WriteObject(list1,
    True,0)
    ra.WriteObject(recogsize,
    True,ra.CurrentPosition)
    ra.WriteObject(recoglist,
    True,ra.CurrentPosition)
    ra.Close
    but when read with this code the bitmap is null

    Code:
    Dim ra As RandomAccessFile
    ra.Initialize(
    File.DirInternal,"gamelist",False)
    list1 = ra.ReadObject(
    0)
    recogsize = ra.ReadObject(ra.CurrentPosition)
    recoglist = ra.ReadObject(ra.CurrentPosition)
    ra.Close
    gamelist.Clear
    For i = 0 To list1.Size-1
    gamelist.AddTwoLinesAndBitmap(list1.Get(i),recogsize.Get(list1.Get(i))&
    " MB",recoglist.Get(list1.Get(i)))
    Next
    every thing is ok just bitmap is null
     
    Last edited: Jan 29, 2015
  6. Erel

    Erel Administrator Staff Member Licensed User

    You are writing a List. Not ListView (which you cannot write this way).
     
  7. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    see the code above i was editing
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    See my answer in post #2.

    I recommend you to use KeyValueStore class instead. It does support bitmaps.
     
  9. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    random acceess file can support map i put the bitmap in the map not write bitmap

    thnx for your help
     
  10. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    i used the class but when reading return error

    android.database.sqlite.SQLiteException: unknown error: INTEGER data in nativeGetBlob

    Code:
    For i = 0 To list1.Size-1
    Dim ssize As String = recogdata.GetSimple(list1.Get(i))&" MB"
    Dim sbitmap As Bitmap = recogdata.GetBitmap(list1.Get(i))
    gamelist.AddTwoLinesAndBitmap(list1.Get(i),ssize,sbitmap)
    Next
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Post the code that you use to write the data.
     
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