See this tutorial: https://www.b4x.com/android/forum/threads/28953/#content
Compiling generated Java code. Error
B4A line: 125
If CustomView1 Is View Then
javac 1.8.0_25
src\b4a\Animation\Multiple\main.java:588: error: incompatible types: dddd cannot be converted to View
if (mostCurrent._customview1 instanceof android.view.View) {
^
Sub CustomView1_DoubleClick
Log("double")
If CustomView1 Is View Then
Log("view len")
End If
End Sub
Public sub AsView as View
Retrun Mainx
end sub
'Events declaration
#Event: DoubleClick
#Event: SingleClick
'Class module
Sub Class_Globals
Private mTarget As Object
Private mEventName As String
Private btn As Button
Private topPanel As Panel
Private downTime As Long
Private timer1 As Timer
Private Mainx As Panel
End Sub
Public Sub Initialize (TargetModule As Object, EventName As String)
mTarget = TargetModule
mEventName = EventName
timer1.Initialize("timer1", 300)
End Sub
Public Sub DesignerCreateView(Base As Panel, Lbl As Label, Props As Map)
btn.Initialize("")
'create a button and add it to the Base panel.
Base.AddView(btn, 0, 0, Base.Width, Base.Height)
btn.TextSize = Lbl.TextSize
btn.TextColor = Lbl.TextColor
btn.Gravity = Lbl.Gravity
btn.Text = Lbl.Text
btn.Typeface = Lbl.Typeface
topPanel.Initialize("topPanel")
'Add a transparent panel over the button.
'the panel will handle the touch event.
Base.AddView(topPanel, 0, 0, Base.Width, Base.Height)
Mainx=Base
End Sub
Private Sub topPanel_Touch (Action As Int, X As Float, Y As Float)
If Action = topPanel.ACTION_DOWN Then
If downTime + timer1.Interval > DateTime.Now Then
timer1.Enabled = False
'raise the DoubleClick event
CallSub(mTarget, mEventName & "_" & "DoubleClick")
Else
downTime = DateTime.Now
timer1.Enabled = True
End If
End If
End Sub
Private Sub Timer1_Tick
timer1.Enabled = False
'raise the event
CallSub(mTarget, mEventName & "_" & "SingleClick")
End Sub
Your class will never be a subclass of View. This is why you need to expose the AsView property.
Sub CustomMenu_MenuClick
Msgbox("Menu oldu","")
If touchimageview1 Is View Then << Return is TRUE
LogColor(touchimageview1,Colors.Red) '<<< @warwound lib.
Log(CustomHelper) '<<<< my lib
'>>> wavwound lib source >>> https://www.b4x.com/android/forum/threads/touchimageview.15616/
End If
if CustomHelper is view then '<<< return is FALSE
log("this is View based")
end if
(TouchImageView): Left=50, Top=50, Width=336, Height=5334
[ana_panel=(BALayout): Visible=false, Left=0, Top=0, Width=75, Height=75, callback=class b4a.example.main, text=(TextView): Left=0, Top=0, Width=75, Height=75, Text=49%, image_top=(BALayout): Left=0, Top=-762, Width=75, Height=762, image_name_corner_p=55.png, image_name_corner_n=55.png, image_left=(BALayout): Left=-1920, Top=0, Width=480, Height=75, eventname=CustomHelper, image_corner_p=(Bitmap): 48 x 48, image_corner_n=(Bitmap): 48 x 48, image=(ImageView): Left=0, Top=0, Width=75, Height=75, cx=0, first_touch=0.0, cy=0, horizontal_anchor=true
Your class will never be a subclass of View. This is why you need to expose the AsView property.
No; I cant any example.Are you building a Java library?
You can post a feature request in the wishlist forum. Make sure to explain why do you need this feature (it is not clear from this thread).and I want to add wish list this issiu
Now you can say to me
use it:
B4X:Public sub AsView as View Retrun Mainx end sub
Public sub setTop(Top As Int)
Mainx.Top = Top
End sub
You need to know Java in order to write a library in Java. See the tutorials here: https://www.b4x.com/android/forum/forums/libraries-developers-questions.32/
You can post a feature request in the wishlist forum. Make sure to explain why do you need this feature (it is not clear from this thread).
dim stdpanel is panel '<<< standart view
dim custompanel is mylib '<< my lib
'.....
'..... intalize etc codes
animation.translete(stdpanel,0,0,100,100)
animation.start
animation.translete(custompanel.asView,0,0,100,100)
animation.start
animation.translete(custompanel,0,0,100,100)
animation.start
It should work. If you want then set top, left, width... of your custom view, you can use MyCustomView.AsView.Top = ...
or, if your "view" has Top property:
B4X:Public sub setTop(Top As Int) Mainx.Top = Top End sub
My thread is not clear... sorry my bad english.
If touchimageview1 IsViewThen << ReturnisTRUE
LogColor(touchimageview1,Colors.Red) '<<< @warwound lib. Log(CustomHelper) '<<<< my lib
'>>> wavwound lib source >>> https://www.b4x.com/android/forum/threads/touchimageview.15616/EndIf