how we can get the arraylist(both string and integer) from the resources xml

前端 未结 5 1677
太阳男子
太阳男子 2020-12-29 20:22

Hi want to get the arraylist from the resources.xml is there any code for this.please give me some suggestions.Thanks in advance

5条回答
  •  清歌不尽
    2020-12-29 21:13

    I have done this way:

    string.xml:

    Define String Array:

     
            Test 1
            Test 2
            Test 3
            Test 4
            Test 5
            Test 6
    
        
    

    In Activity.class / Fragment.class:

    List myArrayList = Arrays.asList(getResources().getStringArray(R.array.my_string_array));
    

    Done

提交回复
热议问题