android nested listview

后端 未结 5 2194
别跟我提以往
别跟我提以往 2020-11-27 05:15

is it possible/advisable to have a nested listview?

i.e. a listView that\'s contained within a row of another listview?

an example would be where my main lis

5条回答
  •  独厮守ぢ
    2020-11-27 06:05

    I had the same problem today, so this is what I did to solve it:

    I have a ListView, with a CustomAdapter, and on the getView of the customAdapter, I have something like this:

    LinearLayout list = (LinearLayout) myView.findViewById(R.id.list_musics);
    list.removeAllViews();
    
    for (Music music : albums.get(position).musics) {
        View line = li.inflate(R.layout.inside_row, null);
    
        /* nested list's stuff */
    
        list.addView(line);
    }
    

    So, resuming, It's not possible to nest to ListViews, but you can create a list inside a row using LinearLayout and populating it with code.

提交回复
热议问题