B4A Library EmphasisTextView

It wraps this Github project. Just something to highlight selected text within a string of text. Posting the B4A library files and B4A project.

1.png


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: EmphasisTextView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private etv1, etv2 As EmphasisTextView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
    etv1.Text = "Napoleon said: Able was I ere I saw Elba"
    etv1.TextToHighlight = "le"
    etv1.TextSize = 25
    etv1.CaseInsensitive = True
    etv1.TextHighlightColor = "#ffffff00"
    etv1.highlight
   
    etv2.Text = "Napoleon said: Able was I ere I saw Elba"
    etv2.TextToHighlight = "sa"
    etv2.TextSize = 25
    etv2.CaseInsensitive = True
    etv2.TextHighlightColor = "#ff00ffff"
    etv2.highlight   

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • EmphasisTextViewLibFiles.zip
    4.6 KB · Views: 211
  • b4aEmphasisTextView.zip
    7.9 KB · Views: 204

Johan Schoeman

Expert
Licensed User
Longtime User
I have used "Able was I ere I saw Elba" on purpose. Have you noticed that it reads the same regardless of one reading it from left to right or from right to left?
 

Dave O

Well-Known Member
Licensed User
Longtime User
Hi, I'm trying to replace a label in @Informatix's UltimateListView with an EmphasisTextView, but on compile I get this error when I call panel.GetView:

B4X:
Dim noteLabel As EmphasisTextView = LayoutPanel.G
javac 1.8.0_73
src\net\dobrien\quickproto\search.java:887: error: cannot find symbol
_notelabel.setObject((main.java.com.athkalia.emphasis.EmphasisTextView)(_layoutpanel.GetView((int) (2)).getObject()));
  ^
  symbol:  class java
  location: class main

I'm assuming that GetView expects to get a view back, and perhaps EmphasisTextView is not compatible?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi, I'm trying to replace a label in @Informatix's UltimateListView with an EmphasisTextView, but on compile I get this error when I call panel.GetView:

B4X:
Dim noteLabel As EmphasisTextView = LayoutPanel.G
javac 1.8.0_73
src\net\dobrien\quickproto\search.java:887: error: cannot find symbol
_notelabel.setObject((main.java.com.athkalia.emphasis.EmphasisTextView)(_layoutpanel.GetView((int) (2)).getObject()));
  ^
  symbol:  class java
  location: class main

I'm assuming that GetView expects to get a view back, and perhaps EmphasisTextView is not compatible?
I am not familiar with UltimateListView. Can you add a panel to ULV? If you can, then add the EmphasisTextview to a panel. If not, what about adding the ETV to a panel, convert the panel to a Bitmap, and then add the Bitmap to ULV?
 

Dave O

Well-Known Member
Licensed User
Longtime User
I think adding the ETV inside a panel should work. Thanks.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Great Johan is possibile defined metacharacter tags:

Type

B4X:
 etv1.Text = "Napoleon said: {R}Able was I {R}ere I saw Elba"
 etv1.TextToHighlight = {R}
 etv1.TextSize = 25
 etv1.CaseInsensitive = True
 etv1.TextHighlightColor = "#ffffff00"
 etv1.highlight

So i have "Able was I" in Highlight.
Thank you
Have nice day
Marco
 
Top