Android Tutorial Action List module - Creating a custom view

Discussion in 'Tutorials & Examples' started by Erel, Jan 24, 2012.

  1. koaunglay

    koaunglay Member Licensed User

    Please help! I'm writing my first ringtoneapk. When user longclick on imageview I want to show ActionList. But I get some error.
     

    Attached Files:

    • 2.png
      2.png
      File size:
      105.1 KB
      Views:
      129
  2. koaunglay

    koaunglay Member Licensed User

    This is my somecode!
    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
            Activity.LoadLayout("sv")
       
            bgsv.Panel.LoadLayout(
    "pn")
                bgsv.Panel.Height = pan.Height
                
    ' ////////////// This is for list ....
                al = ActionListModule.InitializeList(90%x"Choose action""Main")
                ActionListModule.AddActionItem(al, 
    "RingTone "LoadBitmap(File.DirAssets, "bomb.png"), 1)
                ActionListModule.AddActionItem(al, 
    "MessageTone "Null2)
                ActionListModule.AddActionItem(al, 
    "AlernTone "Null3)
                ActionListModule.AddActionItem(al, 
    "AllTone "Null4)
                
    ' ////////////////////
    End Sub

    Sub iv_LongClick
        
    Dim vvv As ImageView
        vvv = 
    Sender

            
    Select vvv.Tag
                
    Case "m1"
                    
    ToastMessageShow("Clicked 111111111"False)
                    
    '--------------------------------------------------------------------
                    ActionListModule.Show(al, Activity10dip10dip)
                
    Case "m2"
                    
    ToastMessageShow("Clicked 22222222"False)
                
    Case "m3"
                    
    ToastMessageShow("Clicked 333333333333"False)
                
    Case "m4"
                    
    ToastMessageShow("Clicked 444444444"False)
            
    End Select
    End Sub
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the full error message from the logs?
     
  4. koaunglay

    koaunglay Member Licensed User

    Now I'm writing ringtone apk. When I click on one Imageview, I want to show List. So I use this ActionListModule. But I get some error.
    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
            Activity.LoadLayout("sv")
      
            bgsv.Panel.LoadLayout(
    "pn")
                bgsv.Panel.Height = pan.Height
                
    ' ////////////// This is for list ....
                al = ActionListModule.InitializeList(90%x"Choose action""Main")
                ActionListModule.AddActionItem(al, 
    "RingTone "LoadBitmap(File.DirAssets, "bomb.png"), 1)
                ActionListModule.AddActionItem(al, 
    "MessageTone "Null2)
                ActionListModule.AddActionItem(al, 
    "AlernTone "Null3)
                ActionListModule.AddActionItem(al, 
    "AllTone "Null4)
                
    ' ////////////////////
    End Sub
    This is for Longclick
    Code:
    Sub iv_LongClick
        
    Dim vvv As ImageView
        vvv = 
    Sender

            
    Select vvv.Tag
                
    Case "m1"
                    
    ToastMessageShow("Clicked 111111111"False)
                    
    '--------------------------------------------------------------------
                    ActionListModule.Show(al, Activity10dip10dip)
                
    Case "m2"
                    
    ToastMessageShow("Clicked 22222222"False)
                
    Case "m3"
                    
    ToastMessageShow("Clicked 333333333333"False)
                
    Case "m4"
                    
    ToastMessageShow("Clicked 444444444"False)
            
    End Select
    End Sub
    And This is for Globals
    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim al As ActionList
        
    ' ---------------------------------
        Private bgsv As ScrollView
        
    Private btn1 As Button
            
    ' ------------------------
            Dim ani As AnimationPlus
            
    Dim mp As MediaPlayer
            
    ' ----------------------------
        Private imv1 As ImageView
        
    Private imv2 As ImageView
        
    Private imv3 As ImageView
        
    Private pan As Panel
        
    Private imv10 As ImageView
        
    Private imv11 As ImageView
        
    Private imv12 As ImageView
        
    Private imv13 As ImageView
        
    Private imv14 As ImageView
        
    Private imv15 As ImageView
        
    Private imv4 As ImageView
        
    Private imv5 As ImageView
        
    Private imv6 As ImageView
        
    Private imv7 As ImageView
        
    Private imv8 As ImageView
        
    Private imv9 As ImageView
    End Sub
    I want to make for choose
     
  5. koaunglay

    koaunglay Member Licensed User

    This is error Pic
    and myzip file
     

    Attached Files:

  6. koaunglay

    koaunglay Member Licensed User

    I don't know how should I copy and post the full error message from the logs. so I post The Image file
     

    Attached Files:

    • 2.png
      2.png
      File size:
      41.3 KB
      Views:
      121
  7. Erel

    Erel Administrator Staff Member Licensed User

    You can right click on the logs to copy them.

    Can you upload your project (File - Export as zip)?
     
  8. koaunglay

    koaunglay Member Licensed User

    Thanks
    Erel! This is my zip
    Code:
    LogCat connected to: ?



    Note: 
    log switch off, only log_main and log_events will have logs!


    --------- beginning of /dev/
    log/main
    ** 
    Activity (main) Create, isFirst = true **


    ** 
    Activity (main) Resume **


    ** 
    Activity (main) Pause, UserClosed = false **


    ** 
    Activity (ring) Create, isFirst = true **


    java.lang.NoSuchFieldException: bg


        at java.lang.Class.getDeclaredField(Class.java:
    631)
        at anywheresoftware.b4a.agraham.reflection.Reflection.GetStaticField(Reflection.java:
    371)
        at b4a.example.actionlistmodule._createninepatchdrawable(actionlistmodule.java:
    160)
        at b4a.example.actionlistmodule._initializelist(actionlistmodule.java:
    216)
        at b4a.example.ring._activity_create(ring.java:
    342)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    511)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    175)
        at b4a.example.ring.afterFirstLayout(ring.java:
    98)
        at b4a.example.ring.access$
    100(ring.java:16)
        at b4a.example.ring$WaitForLayout.run(ring.java:
    76)
        at android.os.Handler.handleCallback(Handler.java:
    615)
        at android.os.Handler.dispatchMessage(Handler.java:
    92)
        at android.os.Looper.loop(Looper.java:
    137)
        at android.app.ActivityThread.main(ActivityThread.java:
    4791)
        at java.lang.reflect.Method.invokeNative(Native Method)


        at java.lang.reflect.Method.invoke(Method.java:
    511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
    789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    556)
        at dalvik.system.NativeStart.main(Native Method)
    java.lang.NoSuchFieldException: bg
     

    Attached Files:

  9. Erel

    Erel Administrator Staff Member Licensed User

    Copy bg.png from the example package to Objects\res\drawable and make sure that it is read-only.
     
    koaunglay likes this.
  10. koaunglay

    koaunglay Member Licensed User

    Thanks Erel! I'll try like that. So happy for your reply!
     
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