Android Question B4XView - Error compiling a code module to library

LucaMs

Expert
Licensed User
Longtime User
I have a code module (b4a) in which all the routines require variables of type B4XView as parameters.

This code module works well in b4a and b4j projects. I compiled the module to a b4a library.

Then I ran the same project (b4a) which used the code module, replacing the module with the library and I get this error at compilation time:

src\b4a\example\main.java:432: error: incompatible types: Button cannot be converted to B4XViewWrapper
parent.mostCurrent._xviewpos._viewsetrelright(mostCurrent.activityBA,(anywheresoftware.b4a.objects.B4XViewWrapper)(parent.mostCurrent._btntomove.getObject()),(anywheresoftware.b4a.objects.B4XViewWrapper)(parent.mostCurrent._button2.getObject()),(int) (0));


P.S. I watched xCustomListView. In it, Add requires a B4XView as parameter (name pnl) and it works :eek:

P.P.S. Works it? I'm not sure, always used as class.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I really don't understand.

xCustomListview has a method (Add) that requires a B4XView object (Pnl) as parameter. It works as class and even compiled as library.

My module (post #1) does not work if compiled.

I "worked" on the ClockView example:
https://www.b4x.com/android/forum/threads/b4x-xui-creating-custom-views-with-xui.85115/#content

It works even if compiled.
I added just a single routine to the original source code:
B4X:
Public Sub MoveView(V As B4XView)
    If V.Left = 0 Then
        V.Left = V.Parent.Width - V.Width
    Else
        v.Left = 0
    End If
End Sub

Then the modified ClockView works if used as class, added to a project as class; but it's impossible to use the compiled version (same error message - see post #1).


So this works (xCustomListView):
B4X:
Public Sub Add(Pnl As B4XView, Value As Object)

this not ("my" ClockView):
B4X:
Public Sub MoveView(V As B4XView)

:eek::eek::eek:
 

Attachments

  • xClockView lm.zip
    10.1 KB · Views: 342
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, I don't understand.
I tried your project and it works as expected!?
So where is the problem?
I loaded you project from post#2.
I compiled it as is, and it works.
I compiled it to a library.
Refreshed the Library Manager Tab and checked xClockView.
Then, I removed the ClockView module and the program works as expected !
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Instead you understood correctly, Klaus.

Can you try the project I'm attaching? It is a test with the view compiled.

I still get this error:

B4A line: 45
ClockView1.MoveView(Button1)
javac 1.8.0_66
src\b4a\example\main.java:412: error: incompatible types: Button cannot be converted to B4XViewWrapper
mostCurrent._clockview1._moveview((anywheresoftware.b4a.objects.B4XViewWrapper)(mostCurrent._button1.getObject()));



^


[Note that the "main problem" started with a code module compiled as library, the rest was tests]
 

Attachments

  • xClockView lm lib test.zip
    9.3 KB · Views: 283
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You must check the XUI library in your project!
upload_2018-5-8_21-20-22.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Maybe I'm wrong but you can create code modules and classes (custom view) for all the three platforms (B4A, B4J, B4I) but then you have to compile three different libraries, one for each platform.


P.S. If there are XUI, jXUI and iXUI this is sure.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
There are three different XUI libraries, each product has its own.
When you develop an XUI class, the code is the same for all three products, the same file.
But, if you want to compile it to a library, you must compile one library for each product!
I suppose that with your library you still need to declare the XUI library in the main code because you transmit an object which needs to be transformed into a B4XView.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I was not on this Earth, yestardey :(:D

The "nice" thing is that I wanted to post some very simple routines in Snippets or suggest Erel to implement these routines directly in the Core.

Then I preferred to use a code module and after that I wanted to compile it.

I must say that in this case it is perhaps not very useful to use XUI.

As soon as I'm better I'll evaluate where and what to publish.


Thank you
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
or suggest Erel to implement these routines
Right now I'm thinking to develop to a very nice app, which will not be much loved by "someone":

a list of "Wishes" to be clicked only by b4x members, of course, and a statistic with the most clicked.

Here, this is one of those posts that do not make me very well liked.

:)

So, why I post this? Because I am stupid, of course :D
 
Upvote 0
Top