Android Question Draw Text Italic

nazilabdulla

Member
Licensed User
Longtime User
B4X:
Dim Canvas1 As Canvas
Dim x1,y1 As Int
Dim Text As String
Text="Some Thing Write Here"
x1=10
y1=10
Canvas1.DrawText(Text,x1,y1,Typeface.STYLE_ITALIC,Colors.Black,"LEFT")

Error : STYLE_ITALIC type do not match,

Plz give me solution

Thanks in advance
 

nazilabdulla

Member
Licensed User
Longtime User

Error :

java.lang.RuntimeException: Object should first be initialized (Typeface).

Not working
 
Upvote 0

nazilabdulla

Member
Licensed User
Longtime User
typeface not initialize by this code


B4X:
(Exception) java.lang.Exception:  java.lang.RuntimeException: Object should first be initialized (Typeface).
Error occurred on line: 874 (ObjQuestion)
java.lang.RuntimeException: Object should first be initialized (Typeface).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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 java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.example.objquestion._drawtext(objquestion.java:1050)
    at b4a.example.objquestion._setcanvas(objquestion.java:2456)
    at b4a.example.objquestion._setquestionandoptions(objquestion.java:688)
    at b4a.example.objquestion._designercreateview(objquestion.java:497)
    at b4a.example.test$ResumableSub_GetQuestionNumbers.resume(test.java:255)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6892)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
(Exception) java.lang.Exception:  java.lang.RuntimeException: Object should first be initialized (Typeface).
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This works:
B4X:
Private tf As Typeface
tf = Typeface.CreateNew(Typeface.DEFAULT, Typeface.STYLE_ITALIC)
Canvas1.DrawText(Text, x1, y1, tf, Colors.Black, "LEFT")
And this one too.
B4X:
cvsActivity.DrawText("Test text", 20dip, 150dip, Typeface.CreateNew(Typeface.DEFAULT, Typeface.STYLE_ITALIC), 20, Colors.Blue, "LEFT")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…