Android Question Code Snippets

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all!

Today I installed B4A 12.80 and tried to see how the code snippets work. I opened my exisitng project and typed a keyword code - only 2 lines appears in the list - see a screenshot screen1.

Then I created a new project and tried to type the same keyword code - nothing comes up at all - screenshot screen2. I also attched a zip with this mew project.

What am I doing wrong?
 

Attachments

  • screen1.png
    screen1.png
    104.9 KB · Views: 136
  • screen2.png
    screen2.png
    82.7 KB · Views: 136
  • TestSnippets.zip
    8.7 KB · Views: 123

William Lancee

Well-Known Member
Licensed User
Longtime User
There is a tutorial. It first first came out in B4J, but is equally valid for B4A.

https://www.b4x.com/android/forum/threads/b4x-code-snippets.152450/

The snippet you want to copy using IntelliSense needs to be in a separate Snippet Folder in B4X Subfolder of Additional Libraries
additionalLibs>B4X>Snippets>aSnippet.txt
Each snippet is a text file. Take a look at the examples.

You have to make your own collection of snippets, based on your own favorite codes or the numerous examples on this forum.
If you change or add a snippet while inside the IDE, make sure to refresh (right click) in the Libraries Manager panel.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
There is a tutorial. It first first came out in B4J, but is equally valid for B4A.

https://www.b4x.com/android/forum/threads/b4x-code-snippets.152450/

The snippet you want to copy using IntelliSense needs to be in a separate Snippet Folder in B4X Subfolder of Additional Libraries
additionalLibs>B4X>Snippets>aSnippet.txt
Each snippet is a text file. Take a look at the examples.

You have to make your own collection of snippets, based on your own favorite codes or the numerous examples on this forum.
If you change or add a snippet while inside the IDE, make sure to refresh (right click) in the Libraries Manager panel.
Thank you for your help. But why it works in one project and doesn't work i another?
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
The problem couldn't be that, the fact that one (any) library hadn't been imported, the snippets would still have been available.
Unless the snippets were a part of the library, right? (Which isn't relevant to the issue @Alex_197 posted about, just asking for completeness.)
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
:oops:

The problem couldn't be that, the fact that one (any) library hadn't been imported, the snippets would still have been available.
Ok, you might be right but added the library solved the problem. But it raised a question - how the snippets are linked to the lib?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
But it raised a question - how the snippets are linked to the lib?


If you extract the library you will see an included folder named ....

Capture.png
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
To Expand on @LucaMs reply ..

Deselect OKHttpUtils2 and you will still see snippets that you have created and stored in your Additional Library / Snippets Folder .
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
With the test project in post#1, if the OkHttpUtils2 library is selected you will see two code snippets specific for this library.
When you un-select the OkHttpUtils2 library these two code snippets disappear and this is as it should be.
Why display a lot of snippets for libraries you do not use.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
With the test project in post#1, if the OkHttpUtils2 library is selected you will see two code snippets specific for this library.
When you un-select the OkHttpUtils2 library these two code snippets disappear and this is as it should be.
Why display a lot of snippets for libraries you do not use.
The editor does not investigate, it certainly does not sift through YOUR snippets to try to understand which libraries are needed for them!
 
Upvote 0
Top