ListView in android from 2 dynamic strings arrays

后端 未结 3 869
生来不讨喜
生来不讨喜 2021-01-29 08:15

I have two string arrays, here s1[] contains a list of names and s2[] contains URL\'s associated with the respective name, now i need to populate ListView, with the names and on

3条回答
  •  借酒劲吻你
    2021-01-29 08:41

    Create a class like:

    class Link{
        public String name;
        public String link;
    }
    

    You can then create a custom listview which extends 'ArrayAdapter' and override 'getView' as well as 'onItemSelected'. In both of these method you will be able to get the item using the 'position' parameter.

提交回复
热议问题