Creating a ListView with custom list items programmatically in Android - no xml list item layout

后端 未结 2 869
野性不改
野性不改 2021-01-02 01:27

As I have seen on previously asked questions, inside the custom adapter class (say, MyAdapter extends ArrayAdapter) they always use an inflated xml list-item layout. What I

2条回答
  •  半阙折子戏
    2021-01-02 02:15

    To add to the above answer, setting id with a constant number is not a good idea.

    Replace, listLayout.setId(5000); with,listLayout.setId(View.generateViewId());

    In case you are targeting API 16 and below, refer this.

提交回复
热议问题