I want to use a for loop like this:
`button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Object.setList();
for(int i = 0; i < Object.getList.size(); i++)
if(!Object.getList.get(i).trim().toLowerCase().contains("hello")) {
Toast.makeText(getContext(), "List does not contain "Hello", Toast.LENGTH_LONG).show;
}
}`
This is my model:
public class Object {
private ArrayList<String> mArrayList;
public void setList() {
mArrayList = new Arraylist<>();
mArrayList.add("Hello World!");
mArrayList.add("Random Message");
mArrayList.add("ZZZZ")
}
public ArrayList<String> getList() {
return mArrayList;
}
}
I still keep getting the Toast message, but it works just fine when i use:
if(!Object.getList().toString.trim().toLowerCase().contains("hello"))
Aucun commentaire:
Enregistrer un commentaire