Android Question [SOLVED]JavaObject RunMethod Perform Click Error on B4XComboBox

mechanicaltesla

Member
Licensed User
Hi,

  1. I have a simple example of B4XComboBox and Spinner. when I do JavaObject. RunMethod("performClick",Null) it works on Spinner but not on B4XComboBox (see attached picture)
  2. Is it possible to have "perform click" another way/other means for B4XComboBox?
  3. Any help is appreciated


B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
  
    B4XComboBox1.cmbBox.AddAll(Array As String("Monday","tuesday","Friday","test1"))
    Spinner1.AddAll(Array As String("Monday","tuesday","Friday","test2"))
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Label1_Click
    Dim j As JavaObject = B4XComboBox1
    j.RunMethod("performClick",Null)
End Sub

Sub Label2_Click
    Dim j As JavaObject = Spinner1
    j.RunMethod("performClick",Null)
End Sub

Error for Label1 Clicked for B4XComobox1
java.lang.RuntimeException: Method: performClick not found in: b4a.example.b4xcombobox
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at b4a.example.b4xmainpage._label1_click(b4xmainpage.java:121)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6257)
at android.widget.TextView.performClick(TextView.java:11145)
at android.view.View$PerformClick.run(View.java:23705)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6836)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
 

Attachments

  • examplecombos.png
    examplecombos.png
    37.9 KB · Views: 153
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
performClick is a method present in some native views like spinner and button.

B4XComboBox is not a native view, you cannot manage it with javaobject as if it were native.

try this:
B4X:
Dim NativeSpinner As Spinner = B4XComboBox1.cmbBox
Dim j As JavaObject = NativeSpinner 
j.RunMethod("performClick",Null)
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Any help is appreciated
Would something like this suit your need.
B4X:
Sub Label1_Click
    Dim j As JavaObject = B4XComboBox1.cmbBox
    j.RunMethod("performClick",Null)
    Log(B4XComboBox1.SelectedItem)
    Label1.Text=B4XComboBox1.SelectedItem
End Sub

Sub Label2_Click
    Dim j As JavaObject = Spinner1
    j.RunMethod("performClick",Null)
    Log(Spinner1.SelectedItem)
    Label2.Text=Spinner1.SelectedItem
End Sub
 
Upvote 0
Top