How to create a dictionary app in Sketchware?

An android app for a dictionary can be created in sketchware using File:shared preferences component. Follow the steps below to create a dictionary app.

1. Start a new project in Sketchware.

2. In VIEW area of project, insert a Linear (H) with Edittext, and a Linear (V) with a ListView and two Textviews.


3. In LOGIC area add a new File (shared preference) component.

4. Go to onCreate event and more blocks named Awords, Bwords, Cwords, etc.


5. Also add a string list and a number variable.



6. In Awords, sequentially add words starting with letter A to file with an integer as key; then add meaning of each word to file with the word itself as key. Similarly add words and meanings to file for defining Bwords, Cwords, etc.


7. In onCreate event, add all words to file by using more blocks. Also add all words to the list and ListView. Use blocks as shown in the image below.


Important update: It is recommended not to use the if...else.. block for adding Awords, Bwords, etc. as shown in the videos given below, because then it may not be possible to update the app.

8. Now add events Edittext onTextChanged and ListView onItemClicked.

9. In event Edittext onTextChanged, search file for words with characters entered in Edittext and display them in ListView, using blocks as in the images below.


To be able to search for words with both upper and lower case characters, replace
If (File f getData key (toString a without decimal) substring 0 to length of charSeq) contains (charSeq)
with
If toLowerCase(File f getData key (toString a without decimal) substring 0 to length of charSeq) contains toLowerCase(charSeq)

10. In event ListView onItemClicked, display the meaning of the word clicked, by using blocks as shown in the image below.

Important update: In order to hide the keyboard when an item is selected from ListView, Insert an add source directly block here and put following code in it:
android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

11. Save and run the project.

That's all. The dictionary app is ready.

Watch the video below, to understand better: