0

For example if I have a class:

class Folder {
    public String name;
    public ArrayList<Folder> subFolders;
    public ArrayList<Folder> subFolders;
}

And I am trying to fill ListView with custom ArrayAdapter and then navigate through this ArrayList "Folders" which is filled with data. I try something like this to show subFolders:

private OnItemClickListener listlistener = new OnItemClickListener() {

    @Override
    public void onItemClick(int position, long arg3) {
        currentFolder = (Category) parent.getItemAtPosition(position);
        folders = currentFolder.subFolders;
        folderAdapter.notifyDataSetChanged();
    }
};

But it does not work. Is there any suggestions to help solving this problem?

pepela
  • 423
  • 5
  • 17

1 Answers1

0

In your custom ArrayAdapter create a Public method

public void setList(List<Item> items){
   this.items = items;
}

and now

private OnItemClickListener listlistener = new OnItemClickListener() {

    @Override
    public void onItemClick(int position, long arg3) {

        currentFolder = (Category) parent.getItemAtPosition(position);

        folders = currentFolder.subFolders;
        folderAdapter.setList(folders);
        folderAdapter.notifyDataSetChanged();

    }
};
Kapil Vats
  • 5,375
  • 1
  • 24
  • 30