How to create a custom ListView in Sketchware?

The recently added Custom View in Sketchware can be used to create custom ListView. The steps you need to follow in order to create a custom ListView are given below.


1. In VIEW area of your sketchware project, add a ListView.

2. Add a new CustomView.

3. Now in properties of ListView, select the new view you added as customView.

4. Now in the VIEW area of CustomView, add a Linear (H) and a TextView.

5. In LOGIC area of your app, add a new list Map.

6. In onCreate event in your project, add items to the Map list using a single key. After adding items to list, setListCustomViewData of ListView to List Map (See image below).

7. In LOGIC area of your app add a new event​ ListView: onBindCustomView.

8. In event ListView: onBindCustomView, set the text of TextView in CustomView to the data from list Map.

9. If you want to implement some action on clicking any particular item in CustomView​, use the When view... clicked block available at the place where new variables are added.


10. Save and run the project to see the Custom ListView.

The video below shows how multiple lists can be used in a single Custom ListView.



Comments

  1. how to fix java.lang.NullPointerException. i am fetching data from firebase.. at very first use app is working but when i close app and open it again and open listview activity this error appear and says close application?

    please help.

    ReplyDelete
    Replies
    1. Sir i can not add source directly because i am using letest version of sketchware

      Delete
    2. Sketchware late version is comeback bring addsource directly

      Delete
  2. EditText wigit is not working in custom listview. Solution please...

    ReplyDelete
  3. Can i add this https://rentedfairly.blogspot.com
    to save and find my data , if yes then plz let me know how to do .
    skranjan27@gmail.com

    ReplyDelete
  4. How to fix that EditText isn't working in Custom ListView:
    Just add per 'add source directly'-Block this code:
    edittext1.setEnabled(true);
    edittext1.setClickable(true);
    edittext1.setFocusable(true);
    edittext1.setFocusableInTouchMode(true);

    ReplyDelete
  5. How add search function on custom listview?

    ReplyDelete
    Replies
    1. Search Custom ListView: https://youtu.be/CCgBEtrUFzE

      Delete
  6. And how add file preference on custom listview?

    ReplyDelete
    Replies
    1. Convert the ListMap to Json String and save that String in file shared preferences.

      Delete
  7. Escribo diferentes textos que se ingresan a una listview, pero al cerrar y abrir nuevamemte la app la lista esta vacía, pueden ayudarme?.. no se casi nada de programacion

    ReplyDelete
  8. How to add Custom List view In Drawer....

    ReplyDelete
  9. It doesn't have a "customv" option for me to choose, when I press the button "customView", it only came out with "none" selection. I can't create a customv

    ReplyDelete
  10. How to show new items first in a list view from firebase

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. I want my app run in the background. Like daily alarm app

    ReplyDelete
    Replies
    1. You need to add BackgroundService or BroadcastReceiver. It cannot be done in Sketchware. Maybe be possible in modded Sketchware, I'm not sure.

      Check these:
      https://developer.android.com/guide/components/services

      https://developer.android.com/training/scheduling/alarms

      Delete
  13. Great dear Sanjeev Your page is really helpful.
    I need to make an app that graph and store in diles the numbers received vía Bluetooth. Can You help me with this?
    Hope to get your answer.
    Regards Lino

    ReplyDelete
  14. hi guys ... excuse me i can't find ( In event ListView: onBindCustomView,) can you help me please

    ReplyDelete
    Replies
    1. Me too, can Not find this.. Help please

      Delete
    2. Under event press plus symbol and in opened menu under view you will find it

      Delete
    3. Sorry I find Not this.. I see "View ist empty".

      Delete
  15. is it possible to use "add source directory" in latest version of sketchware? I've added this in a project, where i used custom listview to show data. but its showing nullpointerexcetin report and app is crashing

    ReplyDelete
  16. How can I show only certain positions in a custom listview?

    For example, length of custom listview is 10.

    if i click button 1, I want to show only positions 2, 3 and 6 in the custom list view.

    Is it possible? How?

    ReplyDelete
  17. How can I show only certain positions in a custom listview?

    For example, length of custom listview is 10.

    if i click button 1, I want to show only positions 2, 3 and 6 in the custom list view.

    Is it possible? How?

    ReplyDelete
    Replies
    1. Save the list in file shared preferences after creating list. When button 1 is clicked delete all items except position 2,3,6 and display list in ListView

      Delete
  18. Do i have to use one single key in the list map? I want to know, because it's not working with multiple keys, but i can't produce single key list maps (i get them from firebase)

    ReplyDelete
  19. Sanjeev sir, how could we add and use button in each row of custom listview?

    ReplyDelete
  20. Hi Sanjeev. I need help about customview. I make 15 customview in firebase. Then i made search data in customview. My problem is when i search data 15, the position data 15 become 0. Then when i edit it, the data in position 0 is change not the data 15.
    I will waiting for your reply
    Thank you

    ReplyDelete
  21. How to change a customview to another customview with a block or add soirce directly block? It was annoyed for me when searching

    ReplyDelete
  22. How to display latest chat massage in listview on create activity at bottom.
    Please reply quickly.

    ReplyDelete
  23. Sir,
    I cannot add listview onBindCustomView Event.
    I not found this onBindCustomView in logic area. Please help me. Thank you.

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware