B4A Library #HashTagHelper

This is a library designed for highlighting hashtags ("#example") and catching click on them.It wraps this github project. Enjoy it. https://github.com/Danylo2006/HashTagHelper
HashTagHelper
Version:
0.2
  • HashTagHelper
    Events:
    • onHashTagClicked (hashTag As String)
  • Methods:
    • Handle (textView As TextView)
      Handles A TextView
      textView:
    • Initialize (EventName As String, colorPrimary As Int)
    • IsInitialized As Boolean

Example :

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

    Private HashTagTxt As EditText
    Dim HashTagObj As HashTagHelper
    Dim Txt2 As String = "This #system can #also be used #really well to make #shopping #lists. #Generally, you might #remember an item you #have to #pick up and #message your #better half or your #roommate about it. But as you #continue messaging with #each other, #that item gets lost #somewhere in your chat logs. #Next time, #just add a #hashtag to your #message."
    Dim Txt As String = "A #hashtag can solve that #conundrum. When #someone sends you a #message that you #want to be able to refer to later, just type and send the message #important. #Later, when searching, all you #have to do is look up this tag, #without having to remember any keywords from the #message."
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("Layout1")
    HashTagObj.Initialize("Hth",Colors.Blue)
    HashTagObj.Handle(HashTagTxt)
    HashTagTxt.Text = Txt&Txt2
End Sub

Sub HashTag_onHashTagClicked(HashTag As String)
  ToastMessageShow(HashTag,True)
End Sub
e6aa1f62-aaa6-11e5-911a-c598b6853862.gif
 

Attachments

  • Libraries.zip
    6.8 KB · Views: 276
Last edited:

MhdBoy

Member
Licensed User
Longtime User
thank u it's very useful

I would appreciate it if you add Additionalsymbols feature to this library,I seriously need this feature ,
It is already in the main library in github
 

jahswant

Well-Known Member
Licensed User
Longtime User
Let me investigate.
Done...Please test haven't tested...

B4X:
#Region  Project Attributes
    #ApplicationLabel: HashTag
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #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.
     Dim HashtagHelper As HashTagHelper
     Dim HashtagHelper2 As HashTagHelper
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.
     Dim HestEditText As EditText
     Dim HestEditText2 As EditText
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("Layout1")
   
    Dim Txt2 As String = "This £system can £also be used #really well to make #shopping _lists. #Generally, you might µremember an item you #have to #pick up and #message your #better half or your #roommate about it. But as you #continue messaging with #each other, #that item gets lost #somewhere in your chat logs. #Next time, #just add a #hashtag to your #message."
    Dim Txt As String = "A _hashtag can solve that £conundrum. When $someone sends you a #message that you µwant to be able to refer to later, just type and send the message #important. #Later, when searching, all you #have to do is look up this tag, #without having to remember any keywords from the #message."
   
    HashtagHelper.Initialize("HashtagHelper",Colors.Blue,Array As Char("_", "£", "$", "µ"))
    HashtagHelper2.Initialize("HashtagHelper2",Colors.Black,Array As Char("_", "£", "$", "µ"))
   
    HestEditText.Initialize("HestEditText")
    HestEditText2.Initialize("HestEditText2")
   
    Activity.AddView(HestEditText,10%x,10%y,60%x,20%y)
   
    Activity.AddView(HestEditText2,10%x,30%y,60%x,40%y)
   

    HashtagHelper.Handle(HestEditText)
    HashtagHelper2.Handle(HestEditText2)
   
    HestEditText.Text = Txt
    HestEditText2.Text = Txt2
End Sub

Sub HashtagHelper2_onHashTagClicked(hashTag As String)
    ToastMessageShow(hashTag,True)
End Sub

Sub HashtagHelper_onHashTagClicked(hashTag As String)
    ToastMessageShow(hashTag,True)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • AdditionalLibraries.zip
    7.5 KB · Views: 193

jahswant

Well-Known Member
Licensed User
Longtime User
I just tested and it's functioning as expected. this is the example project.
 

Attachments

  • ZipFile.zip
    7.3 KB · Views: 198
Top