'I want to create a class where the words for the ListView will come from. How i can make it?

I want to create a class where the words for the ListView will come from.

Something like this, what I showed is not working, I did it like this for an example! How to connect them? Like this:

ListViewM.java

package great.biron.dargin;

public class ListViewM {


    private String mWords [] = {
            "Word1",
            "Word2"
    };

}

Dictionary.java

//Variable start
private ListViewM mWords = new ListViewM();
//Variable end

//onCreate
myArrayList.add(mWords);



Solution 1:[1]

You can try this

public class ListViewM {

 public static List<String> getWords() {
     return Arrays.asList("Word1", "Word2");
 };
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marat