Add ListView to Navigation drawer

In the latest version of Sketchware (v2.2.2), appcompat-v7 and design have been added, and we can now add a navigation drawer to our project. This navigation drawer uses a CustomView. But the CustomView in Sketchware doesn't have option to add a ListView.

In order to add a ListView to the drawer, we have to create the ListView programmatically and then add it to the drawer. To know how it can be done follow the steps given below.

1. In your Sketchware android project, go to Library manager and switch on AppCompat and Design.
2. In View manager, go to and select Navigation Drawer Activity.

3. Now go to the CustomView drawer_main and add a LinearV linear1. Set it's width as MATCH_PARENT.

4. Create a new String list mylist.

5. Create a new Intent component i.

6. Now suppose you have five other activities,,,, and

Add a word for each of these activities to the String list mylist, in the onCreate event.

7. In the onCreate event, after adding items to the list, use an add source directly block and put following codes in it.
ListView listview1 = new ListView(this);
LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

listview1.setAdapter(new ArrayAdapter(getBaseContext(), android.R.layout.simple_list_item_1, mylist));


Note that in this code mylist is the name of the String list, _drawer_linear1 represents the linear1 added in the CustomView drawer_main.

This code creates a new ListView listview1, sets it's LayoutParams, sets it's Adapter, and adds it to the LinearLayout linear1 in CustomView drawer_main.

8. After this add another add source directly block and put codes for setting OnItemClickListener for the ListView.
listview1.setOnItemClickListener( new AdapterView.OnItemClickListener() {
public void onItemClick(
AdapterView _parent, View _view, final int _position, long _id) {
switch (_position){

case 0:
i.setClass(getApplicationContext(), SettingsActivity.class);

case 1:
i.setClass(getApplicationContext(), NotesActivity.class);

case 2:
i.setClass(getApplicationContext(), FeedbackActivity.class);

case 3:
i.setClass(getApplicationContext(), PrivacyActivity.class);

case 4:
i.setClass(getApplicationContext(), AboutActivity.class);

Note that here i is Intent component.

9. Save and run the project.


  1. Why complicate with codes if it can be done with blocks and without "list"

  2. we can add listview to it by AIDE

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. 1. Is it possible to change the direction of the drawer from right to left ?.

    2. Is it possible to add a submenu to drawer? it possible to add a switch to the listview?

  6. bro sanjeev, I have any question: 1. how to change size linier drawer 2. how to change colour linier on drawer. thanks

  7. Hi Sanjeev, is it possible add custom listview in drawer with appCompact?

  8. How to add listview with images in drawer....

  9. How can I change the font of a textview widget in drawer view?

  10. Very nice! Thank you for the posts on Sketchware. Very informative.

  11. How to set OnBindCustomView to listview inside drawer layout


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