Home > Back-end >  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. How i can make it?

Time:05-05

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);

CodePudding user response:

You can try this

public class ListViewM {

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